Created
August 28, 2019 20:18
-
-
Save masyanru/4c2c73b0a8905c33329685619e7fb6f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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