mirror of
https://github.com/satwikkansal/wtfpython
synced 2025-07-04 12:28:05 +02:00
Merge 035bde72ef
into d2673bba08
This commit is contained in:
commit
e35778ae8e
1 changed files with 12 additions and 0 deletions
12
else_without_if.txt
vendored
Normal file
12
else_without_if.txt
vendored
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
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.
|
Loading…
Add table
Add a link
Reference in a new issue