def display(board, p1Score, p2Score, round): clearScreen() print("--------------------------------------------------") print("\t\t Round: " + str(round)) print("--------------------------------------------------") print() displayBoard(board) print() print("--------------------------------------------------") print("\t\t Score") print("--------------------------------------------------") print("Player 1: " + str(p1Score) + "\t\tPlayer 2: " + str(p2Score)) print("==================================================") print()
# 2. Initialise an empty dictionary and give it the name `wordsSummary` # 3. Write a loop through the list of words you made in (1). If the dictionary key does not exists, create new key # and assign the value of 1 to it # 4. Otherwise, update the value of this key by adding itself by 1 # 5. Write a function to print a dictionary nicely. # 6. Call this function at the end of your program def printDictionary(wordDictionary): for item in wordDictionary.keys(): print(item + " => " + str(wordDictionary[item])) words = rawSentence.split(" ") wordSummary = {} for word in words: word = word.lower() if (word not in wordSummary.keys()): wordSummary[word] = 1 else: wordSummary[word] = wordSummary[word] + 1 clearScreen() print("--------------------------") print("The Word Counter") print("--------------------------") print("Total words: " + str(len(words))) print() print("Word Count by Word:") print("--------------------------") printDictionary(wordSummary)