Minimal code example:
What the code looks like before pressing enter:
if True:
for i in range(5):
print(i)
else:
print('no break!')
else:|
What I want the code to look like after pressing enter:
if True:
for i in range(5):
print(i)
else:
print('no break!')
else:|
What the code actually looks like after pressing enter:
if True:
for i in range(5):
print(i)
else:
print('no break!')
else:|
Also, starting from
if True:
for i in range(5):
print(i)
else:
print('no break!')
else:|
should end up with the desired behavior shown above too.
Typically, I don't dedent past the point where the else/elif/except/finally keyword could be placed and still be syntactically correct, but in cases like these where we've already "consumed" the for's (or while's or try's) else, we know that the final else must be meant for the if.
Minimal code example:
What the code looks like before pressing
enter:What I want the code to look like after pressing
enter:What the code actually looks like after pressing
enter:Also, starting from
should end up with the desired behavior shown above too.
Typically, I don't dedent past the point where the
else/elif/except/finallykeyword could be placed and still be syntactically correct, but in cases like these where we've already "consumed" thefor's (orwhile's ortry's)else, we know that the finalelsemust be meant for theif.