I've problem with hex() in python 2.7 I want to convert '0777' to hex with user input. but it have problem with using integer with user input.
In [1]: hex(0777)
Out[1]: '0x1ff'
In [2]: hex(777)
Out[2]: '0x309'
In [3]: z = raw_input('enter:')
enter:0777
In [4]: z
Out[4]: '0777'
In [5]: hex(z)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-5-3682d79209b9> in <module>()
----> 1 hex(z)
TypeError: hex() argument can't be converted to hex
In [6]: hex(int(z))
Out[6]: '0x309'
In [7]:
I need 0x1ff but its showing me 0x309, how i can fix it ?
777?int('8',8) -> errorhex(0o777)