in

What happens when you use filter() in python?


I am starting to learn python and I just came across filter(). however, I got a question about what happens when u use filter() in python

so when I use filter, no error occurs:
using filter()

then I tried asking myself why must I use filter() n not just write a function with a loop for each line of the friends list and appends an empty list whenever someone is above 18, so I did this
using function

found out that it gives me an error so I thought it was a problem with my function, so I tried it with my lambda function that works with my filter() and it still gave me an error
enter image description here

so now I am very confused and have totally no idea why filter() allows me to do it but without it I can’t use the >= operator with tuples

sorry in advance if I am asking an illogical question and thank you!



Source: https://stackoverflow.com/questions/70535048/what-happens-when-you-use-filter-in-python

A project feedback tracker for fellow students at the Turing School of Software & Design

Comment: 3D Touch was one of the best technologies Apple ever created, and I still miss it thumbnail

Comment: 3D Touch was one of the best technologies Apple ever created, and I still miss it