Created
July 16, 2017 23:57
-
-
Save r4z0r5/82d004fc2886244536f7dd7b1aafa830 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
#Hexadecimal to Binary conversion without any imports | |
hexnumbers = list('0123456789abcdef') | |
binnumbers = ('0000','0001','0010','0011','0100','0101','0110','0111','1000','1001','1010','1011','1100','1101','1110','1111') | |
print('Hexadecimal numbers are: ', hexnumbers) | |
userinput = input('Enter any hexadecimal number: ') | |
i = 0 | |
result = '' | |
while i != len(userinput): | |
if userinput[i] not in hexnumbers: | |
print('What the fuck? I actually asked for hex numbers only') | |
exit() | |
else: | |
result += str(binnumbers[(hexnumbers.index(userinput[i]))]) + ' ' | |
i += 1 | |
print(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment