Skip elements on a condition based in a list comprehension in python
You have many options to achieve that. With a list comprehension you can do: my_list = [i for i in my_list if i >= 0] With filter(): my_list = filter(lambda i: i >= 0, my_list) Note: In Python 3, filter() returns a filter object (not list), to convert it to a list, you can do: … Read more