I need to create a range skipping over every 4th number, starting from 5. For example, if the range a is from 1-20, then the numbers 5,9,13,17 will be excluded.
a = [1, 2, 3, 4, 6, 7, 8, 10, 11, 12, 14, 15, 16, 18, 19, 20]
What I tried is creating a regular range, and then a second range consisting the numbers I want to skip, and then remove the second range from the first one.
a = list(range(1,21))
b = list(range(5,21,4))
for x in b:
if x in a:
a.remove(x)
This works, but not for a very large range. Is there a more efficient way to do it?