Why am I receiving error for this simple code from Code Academy ,although there is no error in the environment of Code Academy?


#1

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

this code is running simply in in the environment of Code Academy, but when I run that in Python 3 I am receiving


#2

if i rmb correctly, Code academy's python is an older version. I may be wrong though


#3

Do you know what is the problem with?


#4

I answer. as marblexake, it is for older version. Correct as below:

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

print (c)

#5

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