+ 1
What's wrong in it
i = 1 while i <= 50: if i ==5: break else: print(i) i = i + 1 It's showing no output
2 Answers
+ 1
Indentation, you got else for while not for if.
proper should be:
i = 1
while i <= 50:
if i ==5:
break
else:
print(i)
i = i + 1
I can only add that else for while/for loops will be triggered only if there are no breaks/returns in loop
0
Piotr Szajer yesss why I didn't notice that. thanks