0

An error trying to do the loop example

Whenever I try to copy the loop it either output:1 Finished! 2 Finished! 3 Finished! 4 Finished! 5 Finished! or SyntaxError: invalid syntax The SyntaxError program is : >>> i = 1 >>> while i <=5: print(i) i = i+ 1 print("Finished!") please help.

18th May 2019, 11:15 AM
Ű­Ù…ÙˆŰŻ
Ű­Ù…ÙˆŰŻ - avatar
3 Answers
+ 2
The output will be 1 Finished! 2 Finished! 3 Finished! (...) if you indent the code like this: i = 1 while i <=5: print(i) i = i + 1 print("Finished!") # this is part of the while loop and it will raise a SyntaxError if you don't indent at least one line after the if statement: i = 1 while i <=5: print(i) # error: indentation expected i = i + 1 print("Finished!")
18th May 2019, 11:43 AM
Anna
Anna - avatar
+ 1
Can you please post the link to your code as it is in the Playground?
18th May 2019, 11:18 AM
Trigger
Trigger - avatar
0
Please look at the code. Hope it helps you. https://code.sololearn.com/cN3XqX1RrWp4/?ref=app
18th May 2019, 11:23 AM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar