How to convert base 10 to base 2?
lipska the kat
lipskathekat at yahoo.co.uk
Mon Aug 20 04:26:35 EDT 2012
On 20/08/12 08:50, gianpycea at gmail.com wrote:
> Hi,
> as you can argue from the subject, i'm really,really new to python.
> What is the best way to achieve that with python? Because the syntax int('30',2) doesn't seem to work
>>> x = bin(30)[2:]
>>> x
'11110'
>>> int(x, 2)
30
>>>
lipska
--
Lipska the Kat©: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
More information about the Python-list
mailing list