How does the following expression work in python?

Abd*_*P M 16 python

How does the following expression work in python?

>>> 1 ++++++++++++++++++++ 1
2
>>> 1 ++++++++++++++++++++-+ 1
0
Run Code Online (Sandbox Code Playgroud)

I thought this would raise SyntaxError but that was not the case.

小智 12

You have to use the logic of brackets and arithmetic operations for this kind of calculation.

1--2 becomes,

1-(-(2)) = 1-(-2)
         = 1+2
         = 3
Run Code Online (Sandbox Code Playgroud)

1+++1 becomes,

1+(+(+1)) = 2
Run Code Online (Sandbox Code Playgroud)

1++-1 becomes,

1+(+(-1)) = 0
Run Code Online (Sandbox Code Playgroud)