+ 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

23rd Apr 2020, 6:40 AM
Eco Fico
Eco Fico - avatar
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
23rd Apr 2020, 6:44 AM
Piotr Szajer
Piotr Szajer - avatar
0
Piotr Szajer yesss why I didn't notice that. thanks
23rd Apr 2020, 6:47 AM
Eco Fico
Eco Fico - avatar