Lesson 14 "Try It!"


#1

Hello i have seen i have the correct outcome (I think), But however codecademy does not say this is right, i have tried this:

squares = [x**2 for x in range(1,11)]
filter(lambda x: x >=30 and x <=70, squares)

print squares

Which prints out: [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]

I have looked in the forums and there was someone that used another method such as:

squares = [x**2 for x in range(1,11)]
filter(lambda x: x in range(30,71), squares)

This printed out the same as above.

Maybe this is a bug or something?

Any help would be appreciated! :slightly_smiling:

Mike.


#2

Sorry i forgot to mention, this was the error message that followed:

"Oops, try again. It looks like you didn't print the correctly filtered list to the console."


#3

"print" statement solves the problem

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


#4

Aah okay I see, haha :stuck_out_tongue: Thank you for your help!


#5

this work
cuadrados = [i**2 for i in range(1,11)]
print filter(lambda x: x >=30 and x <=70,cuadrados)


#6

It is a bug :smiley:
let me explain why I think so:
print filter(lambda x: x >=30 and x <=70,squares) works but filter(lambda x: x >=30 and x <=70,squares) gives an error???
Same goes for print filter(lambda x: x in range(30, 71), squares) and filter(lambda x: x in range(30, 71), squares) too.


#7

Thanks for explaining, I found out already, I just forgot the "print" statement and that's why it said I did not print our the correct list :stuck_out_tongue: Thanks for your help :slightly_smiling:


#8

I was lookingn forever for this little error haha. Thanks so much


#9

No problemo! Hahah :wink: :3