[Solved] Python : Remove all values from a list in between two values


EDIT:

Sorry, misread your question. I thought you only wanted to keep these values. Changed my code accordingly.

list1 = ["13:00","13:10","13:20","13:30","13:40"]
range_start = "13:10"
range_end = "13:30"

You can use list comprehension with the range condition:

list1 = [x for x in list1 if not(range_start<=x<=range_end)]
print(list1)

You could also use filter on your list:

list1=list(filter(lambda x:not(range_start<=x<=range_end), list1))
print(list1)

4

solved Python : Remove all values from a list in between two values