How to convert he boolean values into integers

Ulrich Eckhardt eckhardt at
Thu Jun 25 08:20:41 EDT 2009

krishna wrote:
> I need to convert 1010100110 boolean value to some think like 2345, if
> its possible then post me your comment on this

Yes, sure. You can simply sum up the digit values and then format them as
decimal number. You can also just look up the number:

  def decode_binary(input):
      for i in range(2**len(input)):
          if bin(i)==input:
              return str(i)

I Hope I was able to help you with your homework! ;^)


Sator Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932

More information about the Python-list mailing list