D
D
DollyPapper2017-09-01 22:24:46
Python
DollyPapper, 2017-09-01 22:24:46

Pre and post increment in python?

Is it possible in Python to do something other than i += 1? Or is that the only way to increment? Can't post increment in it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
SolidMinus, 2017-09-01
@DollyPapper

If you mean ++i and i++, then no
++i - this is equivalent to +(+i), which is parsed into i, as a result ++i == i -> True

>>> ++i == i
True
>>> +(+i) == ++i
True

i++ is not supported

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question