Skip to content

Instantly share code, notes, and snippets.

@masyanru
Created August 28, 2019 20:18
Show Gist options
  • Save masyanru/4c2c73b0a8905c33329685619e7fb6f7 to your computer and use it in GitHub Desktop.
Save masyanru/4c2c73b0a8905c33329685619e7fb6f7 to your computer and use it in GitHub Desktop.
while True:
num = input("Enter a valid binary number (e.g. 0111010): ")
try:
result = int(num, 2)
except ValueError:
print("Wrong type, only a binary number")
continue
print(f"Decimal equivalent to {num} is {result}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment