I'm writing this program that is supposed to convert binary to hex. I have to use the for loop. The part I need is how do I get the program to get the integer and its index number.
my code so far
q = raw_input('asdf ')
p = list(q)
t = [int(x) for x in p]
for i in t:
if i == 1:
w=i*(2**(3-t[x]))
print w
the t[x] part is supposed to be the index number. So what is happening is if its a one then it will multiply by 2^3-(its index number)
How do I refer to the index number?
And how do I get it to sum all the values it gets