Steve Holden wrote:
>   >>> to_bin(0)
> ''

Doh! Oh, yeah...that! ;)

OK...

def to_bin(x):
  out=[]
  while x > 0:
    out.insert(0, str(x % 2))
    x /= 2
  else:
    out.append(str(x))
  return ''.join(out)

Regards,
Jordan

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to