How to convert he boolean values into integers

Discussion in 'Python' started by krishna, Jun 25, 2009.

  1. krishna

    krishna Guest

    Hi Guys,

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

    Advanced thanks for all

    Narayana perumal.G
    krishna, Jun 25, 2009
    1. Advertisements

  2. 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! ;^)

    Ulrich Eckhardt, Jun 25, 2009
    1. Advertisements

  3. krishna

    samwyse Guest

    int('1010100110', 2)
    samwyse, Jun 25, 2009
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.