Answer the question
In order to leave comments, you need to log in
How to create a copy of a list that only contains elements that meet a condition?
Original :
["11", "2", "3", "4", "55"]
condition: len(element) > 1
Copy would be:
["11", "55"]
Is it possible to do this without loops? Are there built-in solutions?
Answer the question
In order to leave comments, you need to log in
>>> lst = ["11", "2", "3", "4", "55"]
>>> new_lst = filter(lambda x: len(x) > 1, lst)
>>> new_lst
['11', '55']
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question