Include example Python code and output with your answers.
>>> 2++2
>>> 2--2
>>> 2+-2
>>> 2-+2
print(2++2) # 2 + (+2) = 4
print(2--2) # 2 - (-2) = 4
print(2+-2) # 2 + (-2) = 0
print(2-+2) # 2 - (+2) = 0
if you have two values without an operator and a space between them, then python will throw the SyntaxError: invalid syntax error
if you omit the quotation mark, you will get the SyntaxError: EOL while scanning string literal error, because it is not possible to determine the beginning or end of the string
python does not allow leading zeros, there will be a SyntaxError error: leading zeros in decimal integer literals are not allowed; use the 0o prefix for octal integers
Comments
Thank you for the clue
Thanks a lot,this was very helpful
Leave a comment