Scrabble


#1

Hi all,

I am do something wrong, but I don’t have any idea what. It is about this exercise: https://www.codecademy.com/paths/computer-science/tracks/cspath-python-objects/modules/cspath-python-dictionaries/projects/scrabble
task 1:

We have provided you with two lists, letters and points . We would like to combine these two into a dictionary that would map a letter to its point value.

Using a list comprehension and zip , create a dictionary called letter_to_points that has the elements of letters as the keys and the elements of points as the values.

When using this line of code:
letter_to_points = {key:value for key, value in zip(letters, points) }

I am getting this response:
File “scrabble.py”, line 4
letter_to_points = {key:value for key, value in zip(letters, points) }
^
SyntaxError: invalid syntax

Clearly I am doing something wrong here, but I dont know what. Probably something easy and stupid, but hey: that’s how learning works right?

Thanks in advance


#2

that is weird, when i run your code:

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]

letter_to_points = {key:value for key, value in zip(letters, points) }
print(letter_to_points)

it goes fine. I did add a print statement, which is reached and printing fine


#3

Thank you, I reset the exercise and right now the same code works. The ‘^’ was pointing somewhere far after the code, I have no clue why, but after the reset the same code works.