Why is the output of the following two list comprehensions different, even though f
and the lambda
function are the same?
f = lambda x: x*x
[f(x) for x in range(10)]
and
[lambda x: x*x for x in range(10)]
Mind you, both type(f)
and type(lambda x: x*x)
return the same type.