Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re Following syntax error in Mac OX10.7 Terminal

15 views
Skip to first unread message

Sergi Pasoev

unread,
Jun 28, 2012, 1:30:42 PM6/28/12
to
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.

David Thomas

unread,
Jun 29, 2012, 11:13:44 AM6/29/12
to
Hi yeah I'm currently learning python 2 at the moment and the tutorial that I am studying doesn't explain about indentation.

MRAB

unread,
Jun 29, 2012, 11:21:56 AM6/29/12
to pytho...@python.org
Really? Indentation is a basic feature of Python!

David Thomas

unread,
Jun 29, 2012, 11:58:57 AM6/29/12
to pytho...@python.org
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.

David Thomas

unread,
Jun 29, 2012, 11:58:57 AM6/29/12
to comp.lan...@googlegroups.com, pytho...@python.org
On Friday, June 29, 2012 4:21:56 PM UTC+1, MRAB wrote:

Ben Finney

unread,
Jun 29, 2012, 12:02:26 PM6/29/12
to
David Thomas <dtho...@me.com> writes:

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

You might be better served by the official Python tutorial
<URL:http://docs.python.org/tutorial/>.

If you work through it from beginning to end, doing each exercise and
experimenting to be sure you understand before moving through, you will
get a good grounding in the fundamentals of the language.

--
\ “Don't worry about what anybody else is going to do. The best |
`\ way to predict the future is to invent it.” —Alan Kay |
_o__) |
Ben Finney

Andrew Berg

unread,
Jun 29, 2012, 10:05:20 PM6/29/12
to comp.lang.python
On 6/29/2012 10:58 AM, David Thomas wrote:
> 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.
--
CPython 3.3.0a4 | Windows NT 6.1.7601.17803
0 new messages