I am working on the scrabble project:https://www.codecademy.com/courses/learn-python-3/projects/scrabble
The last optional step is to " * make your letter_to_points
dictionary able to handle lowercase inputs as well"
My proposed solution to this was to create a dictionary with key:value pairs with the lowercase letters and then merge that list with the original which contained all uppercase characters.
However my final bit of code:
letters_to_points = letters_to_points.update(lower_letters_to_points)
If i run
print(letters_to_points)
it returns none.
I’m curious as to that is returning none, from my understand .update() can be used to merge two dictionaries.
Full code below:
letters = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
points = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 4, 1, 3, 10, 1, 1, 1, 1, 4, 4, 8, 4, 10]
#print(type(letters) is list)
def lower_the_letters(list_):
list_lowered = []
if type(list_) is list:
for string in letters:
list_lowered.append(string.lower())
else:
list_lowered = 'NOT A LIST'
return list_lowered
letters_to_points = {value:key for key, value in zip(points,letters)}
lower_letters_to_points = {value:key for key, value in zip(points,lower_the_letters(letters))}
letters_to_points = letters_to_points.update(lower_letters_to_points)