n++ < 10 syntax error??
cliechti at gmx.net
Sun Jan 13 17:51:57 CET 2002
rihad <rihad at mail.ru> wrote in
news:h7d34ucusarslbdqfhiu2bvsph2lg9bf5t at 4ax.com:
> Hi there, continuing with my foray into the innards of Python, I found
> myself stumbled over this:
> n = 0
> while n++ < 10:
> Gives a syntax error. Changing n++ to ++n compiles fine.... What the
> hell is going on???
> (P.S. I know I can use the "for n in range(10)" idiom, but what's
> wrong with n++?)
there is no pre/post increment in python ++n applies the unary operator +
newer versions of python support += etc.
while n<10: n+=1
i still prefer the for loop with range.
Chris <cliechti at gmx.net>
More information about the Python-list