# 14. Try it Misterious error

#1

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

print filter(lambda x: range(30, 70), squares)

# [1, 4, 9, 16, 25, 36, 49, 64, 81, 100].``````

i get error saying:

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

#2

The error seems pretty spot on. Got a question?

Your lambda is equivalent to this:

``````def unnamed_function(x):
return range(30, 70)``````

Functions are typically expected to do something based on their arguments, this one just returns the same range no matter what `x` is. What is the function supposed to return, and how does that relate to `x`?
What behavior does filter expect that the function has?

#3

``````squares = [x*x for x in range(1, 10)]

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

I still get error:(

``Oops, try again. It looks like your list consists of [1, 4, 9, 16, 25, 36, 49, 64, 81] instead of [1, 4, 9, 16, 25, 36, 49, 64, 81, 100].``

#4

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

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

#5

Have you produced the correct result? If so perhaps you're not presenting it correctly, does it say that the result should be printed? Otherwise you might need to "put" it somewhere else.

#6

My code:
squares = [x**2 for x in range(1,11)]
print squares
print filter(lambda x: x in range (30,70), squares)

#7

You need to do:
x ** 2
not x * x

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

This worked for me, is there a better to accomplish this? I mean the solution seemed to work but I am looking to better understand

#9

A little cleaner

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

`

#11

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