Having a doubt regarding code!


#1



I have a doubt regarding Advance Topics in Python: Try it!

My first code was as follows:

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

My second code which is working is as follows:

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

What's the problem with the first code?


#2

range produces a list:

print range(30,71)

how can a list equal an integer?

you could use x in range(30, 71), that does work


#3

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