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.
3 Antworten
+ 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!")
+ 1
Can you please post the link to your code as it is in the Playground?
0
Please look at the code. Hope it helps you.
https://code.sololearn.com/cN3XqX1RrWp4/?ref=app