Oct-03-2021, 01:51 PM
(This post was last modified: Oct-03-2021, 02:22 PM by Yoriz.
Edit Reason: Added code tags
)
I have a simple code:
my_tuple = (0,1,2,3,4,5,6) foo = list(filter(lambda x: x-0, my_tuple)) print(foo)I know what the output is and that it removes the first entry, the 0. I could also change it as follows:
my_tuple = (0,1,2,3,4,5,6) foo = list(filter(lambda x: x-0 and x-1, my_tuple)) print(foo)I thought that tuples are immutable? How are the 0 and 1 removed? How does this work and what is this x-0 actually doing?