17.14 Try It!...Help!


squares = [X**2 for x in range(1,11)]

print filter(lambda x: x >= 30 and x <= 70, squares)

Can anyone tell me why my code doesn't work for this exercise? I just can't see why it's not working! Thanks so much!



You wrote X instead of x


Unlike c and other low-level languages, python is very "intelligent". You can just write print filter (lambda x: 30 <= x <= 70, squares) instead of x> = 30 and x <= 70 .... python will understand it very well. And it's much more "natural" I find. :slight_smile:


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