Following syntax error in Mac OX10.7 Terminal

D

David Thomas

Hi,
I have the following error regarding a loop tutorial found on http://www.sthurlow.com/python/lesson04/
.... a=a+1
File "<stdin>", line 2
a=a+1
^
IndentationError: expected an indented block

When I run Python IDE it seems to work fine. The following code is:


a=0
while a<10:
a=a+1
print a


Kind regards
 
A

Andrew Berg

Hi,
I have the following error regarding a loop tutorial found on http://www.sthurlow.com/python/lesson04/

... a=a+1
File "<stdin>", line 2
a=a+1
^
IndentationError: expected an indented block

You indented in the IDE, but not in the interpreter. Indent with a space
or a tab. In Python, indentation is syntactically important. Everything
indented will be part of that while loop; the next line that isn't
indented will be considered not part of the loop.
 
D

David Thomas

Thank you very much I didn't realise that the indentation was important. The IDE indents automatically whilst terminal doesn't.
Thanks for pointing it out.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top