Problem with += (augmented assignment)
dale at out-think.NOSPAMco.uk
Wed Dec 13 12:57:52 EST 2000
mjjacob at my-deja.com wrote:
>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
>Is there something terribly wrong with the +=
>operator or is that all my fault?
>Sent via 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.
Business Technology Consultants
More information about the Python-list