1

Since the increment operator ++ is not supported in python, why doesn't it cause an error when prefixing a variable. Example:

i = 3 ++i 

prints 3 on the interactive console. Why is that?

0

2 Answers 2

5

Take a look - it's just a sign:

>>> i = 3 >>> +i 3 >>> ++i 3 >>> +++i 3 >>> -i -3 >>> --i 3 >>> ---i -3 
Sign up to request clarification or add additional context in comments.

1 Comment

Just figured it out a few secs ago. Thanks and answer accepted.
3

Python treats ++i as +(+i), that would compile fine, and print the same value as of i.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.