I am new to python and I read that there is no ++ operator in Python but I am not able to understand the below code.
>>>print (2++3)
>>>5
I am new to python and I read that there is no ++ operator in Python but I am not able to understand the below code.
>>>print (2++3)
>>>5
+
and -
act as unary as well as binary operators. So,
a ++ b
is same as a + (+b)
a -+ b
is same as a - (+b)
a -- b
is same as a - (-b)
a +- b
is same as a + (-b)
As can be seen below
>>> 2++3
5
>>> 2-+3
-1
>>> 2--3
5
>>> 2+-3
-1
This is not the ++ operator. Your code is interpreted as follows:
2 + (+3)
Now since +3 is 3, the final result is 5. For fun, try the following:
See Expressions for details.