Jump to content

[Python] +- in front of number

17 minutes ago, Teddy07 said:

2+-3 = -1
2-+3 = -1

I am getting into Python and tried to google integer arithmetic but I could not find an answer why both operations above are -1. Both + and - have the same priority so there should be a different outcome

 

Thanks .

2 + -3 = -1
2 - +3 = -1

 

Main: AMD Ryzen 7 5800X3D, Nvidia GTX 1080 Ti, 16 GB 4400 MHz DDR4 Linux - Fedora

Link to post
Share on other sites

56 minutes ago, Sakuriru said:

You also used the assignment operator so that would have caused a runtime error.

true

thanks for the mention. It is a bad idea to write it this way as Python calculated it. I did not assign it. I will write it better in the future

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×