1
0
mirror of https://github.com/satwikkansal/wtfpython synced 2024-09-22 15:41:43 +02:00
wtfpython/else_without_if.txt
Yukti Khosla 035bde72ef
Create else_without_if.txt
Most languages do not allow an else statement without an if.
However, python allows the else statement to be executed without the if provided the loop before it has not been terminated by a break statement.
2020-07-21 20:03:45 +05:30

13 lines
296 B
Plaintext
Vendored

i = 0
while i<=5:
print(i,end=' ')
i += 1
else:
print(i,end=' ')
OUTPUT:
0 1 2 3 4 5 6
Most languages do not allow an else statement without an if.
However, python allows the else statement to be executed without the if provided the loop before it has not been terminated by a break statement.