I have this code that converts binary to hex
## The Input part
l = raw_input('Input 8-bit number: ')
j = list(l)
## Value Error part
t = [int(x) for x in j]
if len(t) != 8 or len([n for n in t if n not in (1, 0)]) != 0:
raise ValueError('NOT 1 OR 0, or NOT CORRECT LENGTH')
## The Conversion part
a = l[0]
b = l[1]
c = l[2]
d = l[3]
e = l[4]
f = l[5]
g = l[6]
h = l[7]
p = a+b+c+d
q = e+f+g+h
y = hex(int(p, 2))[2:]
z = hex(int(q, 2))[2:]
## The Results part
print
print 'Results'
print 'Binary: ',l
print 'Hex: ',y+z
my whole conversion part is insanely long because whenever i try to convert a number that has 0000 in front of it it doesnt print the 0 and i need it to print the 0 is there a way to do this without doing the long process
If I understand you correctly, you want to print out a 2-digit hex number that is gotten from the binary input
l. You can do that as follows: