List Comprehension Syntax Error

(https://www.codecademy.com/paths/computer-science/tracks/cspath-cs-101/modules/cspath-boredless-tourist/projects/the-boredless-tourist)

For question 40: Look up that destination’s attractions by indexing into attractions with destination_index . Save this into the variable attractions_in_city .

I initially tried to do this with a list comprehension, but it was giving me a syntax error. I checked against the learning and I don’t understand how my statement is different from the provided examples.

My attempt:

attractions_with_interest[attraction for attraction in attractions_in_city]

I tried adding in a statement before this where I declared it as a list (but i don’t think this is necessary) and it also didn’t work:

attractions_with_interest =

Hey!

Looking at the question, I don’t think it actually needs a list comprehension or anything like that. I believe it just wants you to select the a single item (at destination_index) from destination using standard item = list[index] syntax. :slight_smile:

1 Like