I found this tutorial on using lambda within python. Upon attempting to do the 3rd example I've discovered the results are not the same as in the tutorial. I'm 99% sure my code is correct, but here it is nonetheless.
my_list = [2,9,10,15,21,30,33,45]
my_new_list = filter(lambda x: x % 3 == 0, my_list)
print(my_new_list)
The result of this is:
<filter object at 0x004F39F0>
Things to keep in mind:
- I'm using Python 3.4.2
- Using Python 2.7.2 work fine and returns
[9, 15, 21, 30, 33, 45]
I understand that it simply doesn't work in Python 3.4+; I'm more curious as to why it doesn't work and also looking for an equal way of doing this, with or without lambda.