Converting an integer to base 2

Stephen Boulet stephen.boulet at
Fri Nov 30 19:29:01 CET 2001

I'm trying to convert integers to base 2. Can someone tell me why this
doesn't work?

>>> int('5', 2)
Traceback (most recent call last):
  File "<pyshell#102>", line 1, in ?
    int('5', 2)
ValueError: invalid literal for int(): 5


-- Stephen

More information about the Python-list mailing list