I got a list of points for each letter:
SCRABBLES_SCORES = [(1, "E A O I N R T L S U"), (2, "D G"), (3, "B C M P"),
(4, "F H V W Y"), (5, "K"), (8, "J X"), (10, "Q Z")]
And in file I have to find word with the highest score
I have a problem, because I don't know how to examine new line. I tried this, but its never ending loop:
max = 0
help = 0
file = open("dictionary.txt", "r")
for line in file:
for l in line:
while(l != '\n'):
help += LETTER_SCORES.get(l)
if(help > max):
max = help
else:
continue
help = 0
print(max)
Does anybody know what Im doing wrong?
[Edit] Mapping for dictionary:
LETTER_SCORES = {letter: score for score, letters in SCRABBLES_SCORES
for letter in letters.split()}