Python Forum

Full Version: Syntax error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi. Trying to learn python using 3.6.0 and having an issue with the print function. 

Using this:
i=1
while i<=5:
           print(i)
           i=i+1
print('Finished')
I keep getting a:
syntaxerror invalid syntax

Can someone help me figure out why I keep getting a syntax error on the print function?

Thanks.
You should use a for loop, rather than while:
for i in range(5):
    print(i)
print('finished')
I do work for me.
Indentation is way of.
Try copy code under:
i = 1
while i <= 5:
    print(i)
    i = i + 1
print('Finished')
To guess,i think you run code in IDLE(Has >>>).
Try File -> New File now paste in code and save with .py extension.
Then Run Module(F5).