i++ in Python?
Peter Hansen
peter at engcorp.com
Thu Jul 18 18:35:08 EDT 2002
OtisUsenet wrote:
>
> Python newbie question. How does one do something like this in
> Python:
>
> # assign the value of j to i and then increment j by 1
> i = j++
>
> I checked the FAQ at http://www.python.org/doc/FAQ.html, but this
> simple question wasn't covered :) I can't find it in 2 Python books
> either.
Is there anything you don't like about doing it exactly as your comment
reads?
>>> i = j
>>> j = j + 1
On newer Pythons, you can replace the second line with j += 1 if you wish.
-Peter
More information about the Python-list
mailing list