Iterating Over A List And Removing Elements After Comparing Them
I'm trying to iterate over a list of number and removing the values that are lower than a number that I use to compare. My problem is that there's a number that is lower than the v
Solution 1:
Using filter
, which keeps only the values that return True
for the lambda function:
list(filter(lambda x: x > 3, [1, 2, 3, 4, 5, 2, 3]))
Output:
[4, 5]
Post a Comment for "Iterating Over A List And Removing Elements After Comparing Them"