Skip to content

Instantly share code, notes, and snippets.

@noahbass
Created November 11, 2014 18:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save noahbass/ed321e69794b8549ebce to your computer and use it in GitHub Desktop.
Save noahbass/ed321e69794b8549ebce to your computer and use it in GitHub Desktop.
convert a binary to an integer
b = '10' # binary input
b = b[::-1]
number = 0
for i in b:
i = int(i)
if i != 0:
number += 2**i
print number
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment