Comprehending Comprehensions: Need help


#1

https://www.codecademy.com/courses/learn-python/lessons/advanced-topics-in-python/exercises/comprehending-comprehensions?action=lesson_resume

Did you create a list called threes_and_fives?

Confused by the error message. Has a list not already been created?

three_and_fives = [x for x in range(1, 16) if (x ** 2) % 3 == 0 or (x ** 2) % 5 == 0]

print three_and_fives

#2

Check the name you have given your list.

Although it makes no difference, I’m a little confused as to why you chose to square x?

Something else of note, due to operator precedence, ** comes before % so the parens are not needed.


#3

Sorry, I was pretty much following the original template given letter by letter, so I forgot to change the x.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.