If you want to express the idea "do something for numbers from 0 to 10, except 6", the correct C++ code for it cannot be a simple for-loop:
for (int i = 0; i <= 10; i++)
{
if (i != 6)
{
... // do the stuff
}
}
You can translate it literally to Python (see answer by tripleee) or make a real one-liner, like so:
Create a list of numbers for which you want to run the stuff: [x for x in range(11) if x != 6]
. Then iterate on it:
for i in [x for x in range(11) if x != 6]:
... # do the stuff
From code readability standpoint, the solution with if
or continue
may be better than this one.