17.14 Try It!...Help!


#1

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!

Bridie


#2

You wrote X instead of x


#3

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:


#5

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