Isn’t this the same as:

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

as

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

Why is the outcome different ?

Isn’t this the same as:

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

as

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

Why is the outcome different ?

You have not set a variable to the value of the filter. Which it is why you are getting the error and why the above two statements are not equivalent.

To clarify:

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

print f

Will result in the intended output (and I think directly adresses your question).

However, it would better to do it the first way.

`print filter`

will simply print the function object, if you add parentheses you call the function (which will execute the function)

I agree, the first way is better. I was trying to get a better understanding. Thanks to both of you!

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