How can I convert a negative number to positive in Python? (And keep a positive one.)
>>> n = -42 >>> -n # if you know n is negative 42 >>> abs(n) # for any n 42
Don't forget to check the docs.
1.4m articles
1.4m replys
5 comments
57.0k users