Remove elements within specific range from a list
I am new here. I'm trying to do below but can not make it to work in case: 1. a = b 2. a not followed by b 3. maybe few more scenarios Any help is highly appreciated. Below is my code: # Given a list of integers of any length, return a new list that does not contain any elements between the range a and b (inclusive) # a may equal to b # every a element may not be followed by b def popa2b(nums,a,b): list = [] ignore = False for i in range(len(nums)): if nums[i] == a: ignore = True if ignore: if nums[i] == b: ignore = False continue list.append(nums[i]) return list a = int(input("Enter a: ")) b = int(input("Enter b: ")) print(popa2b([1, 6, 2, 6, 2, 7, 1, 6, 99, 99, 7],a,b))