Remove the second number from every group of three numbers I have this simple loop that prints numbers from 0 to 29 (30 in total). I want to "split" the results in threes and remove the middle number. So the first set is 0,1,2 and I only want 0,2. The second set is 3,4,5 and I only want 3,5. This works as it supposed too, but is there a way to make it more simpler?

z = 1
for i in range(0,30):
    if z == 1:
        print(i, end=' ')
        z+=1
    elif z == 3:
        print(i, end=' ')
        z=1
    else:
        z+=1


This is the result:

0 2 3 5 6 8 9 11 12 14 15 17 18 20 21 23 24 26 27 29
You want to skip every number of the form 3k+1? Then say that, using a generator expression.

print(' '.join(str(i) for i in range(30) if i % 3 != 1))