Problem with += (augmented assignment)
Dale Strickland-Clark
dale at out-think.NOSPAMco.uk
Wed Dec 13 12:57:52 EST 2000
mjjacob at my-deja.com wrote:
>Hi folks!
>
>I tried this under Python 2.0 running on Win 2k:
>
>x = 0
>while x <= 42:
> x += 1
>
>Python always complains a Syntax Error: Invalid
>Syntax on this:
>
> x += 1
> ^
>SyntaxError: invalid syntax
>
>Augmented assignment only seems to work when used
>in first indentation level (script level).
>Otherwise, I always get that syntax error, it
>does not matter whether I am using if, while or
>whatever.
>
>Is there something terribly wrong with the +=
>operator or is that all my fault?
>
>Help appreciated.
>
>
>Sent via Deja.com
>http://www.deja.com/
I copied your code and pasted it into a new Python script and it worked fine.
Python 2.0 on Win 2K, here too.
I have to assume that either you're not running Python 2 or your done something odd with your tabs.
--
Dale Strickland-Clark
Out-Think Ltd
Business Technology Consultants
More information about the Python-list
mailing list