This commit is contained in:
Yukti Khosla 2024-05-21 15:34:00 +02:00 committed by GitHub
commit e35778ae8e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

12
else_without_if.txt vendored Normal file
View 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.