def scrabble score(words): sumo for letter in vords sum- sumscrabble_map.get(let
ID: 3706388 • Letter: D
Question
def scrabble score(words): sumo for letter in vords sum- sumscrabble_map.get(letter) return sum def read words (file): vordsth for line in open(file): line line.strip) words[1ine-scrabble score(line) return vords print (read words("small.txt" words read words( small.txt naxword max(words, key vords.get) minword min(words, key vords.get print("The vord with the highest score is( withl score (.format (maxvord, scrabble score(maxvord)) print("The vord with the lowest score is owith score ".format (minword, scrabble score(minword))) 'monkey15, 'hotel 8, sock'1 9, foot' 7 The word with the highest Beore ?? monkey with Bcore 15 The word with the 1lovest score is foot with score 7Explanation / Answer
# use this if your words is a list def scrabble_average(words): avg = 0 for value in words: avg += value if len(words) == 0: return 0 return avg / len(words) # if you have a dictionary call this method with .values() # example d = {} scrabble_average(list(d.values())) # if you have a list just call this directly l = [] d = {} scrabble_average(l)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.