Re Following syntax error in Mac OX10.7 Terminal

S

Sergi Pasoev

You just have to consider that indentation matters in Python, so you
have to type the code in Python interpreter as you have written it
below, that is, press Tab before each line when you are inside the
'while (or any other like for, if, with, etc.) block.

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

I can guess from your message that you aren't aware of one very
important Python feature, and maybe you also didn't willingly choose to
learn Python2 instead of Python3 ? In this case I would advise you to
consider both versions before choosing.
 
D

David Thomas

You just have to consider that indentation matters in Python, so you
have to type the code in Python interpreter as you have written it
below, that is, press Tab before each line when you are inside the
'while (or any other like for, if, with, etc.) block.

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

I can guess from your message that you aren't aware of one very
important Python feature, and maybe you also didn't willingly choose to
learn Python2 instead of Python3 ? In this case I would advise you to
consider both versions before choosing.

Hi yeah I'm currently learning python 2 at the moment and the tutorial that I am studying doesn't explain about indentation.
 
M

MRAB

Hi yeah I'm currently learning python 2 at the moment and the tutorial that
I am studying doesn't explain about indentation.
Really? Indentation is a basic feature of Python!
 
D

David Thomas

Really? Indentation is a basic feature of Python!

while {condition that the loop continues}:
{what to do in the loop}
{have it indented, usually four spaces}
{the code here is not looped}
{because it isn't indented}

Just discovered this in the tutorial further down. I'm currently learning Python 2 because there seems to be a lot of tutorials out there covering Python 2 rather than 3.

Thanks for the help this community is great for help.
 
D

David Thomas

Really? Indentation is a basic feature of Python!

while {condition that the loop continues}:
{what to do in the loop}
{have it indented, usually four spaces}
{the code here is not looped}
{because it isn't indented}

Just discovered this in the tutorial further down. I'm currently learning Python 2 because there seems to be a lot of tutorials out there covering Python 2 rather than 3.

Thanks for the help this community is great for help.
 
A

Andrew Berg

Just discovered this in the tutorial further down. I'm currently learning Python 2 because there seems to be a lot of tutorials out there covering Python 2 rather than 3.
The latest edition (3rd?) of Programming Python by Mark Lutz covers py3k
(it targets 3.0/3.1 IIRC, but the official Python docs cover the
differences between versions). The tutorial in the official docs is
short compared to a book, but it covers the basics well. The official
docs do cover each module in the standard library in great detail. It is
mainly reference, though there are a few tutorials (e.g. the logging
module has at least 2 tutorials).

If you are not restricted to 2.x, learn 3.2/3.3. 2.x is used mainly
because some major libraries (e.g., Twisted, Django) and/or other
dependencies do not support 3.x yet. There will be no 2.8, and 2.7 isn't
getting any new features AFAIK.
 

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,774
Messages
2,569,596
Members
45,143
Latest member
SterlingLa
Top