2011-03-30, 03:54 PM
I found out where my mistake was, I misread the way on how to transform from binary to decimal, I rememberd how to but guided myself from the example and screwed it up making it backwards.
The code that gets it right is:
... Thanks for the help, I'll probably ask more things later/this week.. or even after that
Edit: Also, looking and running your code, you use functions I haven't really learned yet xD I hadn't seen enumerate yet, or the way you reversed the number, we do it more... stupidly because we're noobies at my class xD, also we've never used more than one variable in a 'for x in range', when we need more than one we do:
but as I said, still learning.... slowly... xD
The code that gets it right is:
Code:
final=0
n=raw_input('ingresa codigo binario: ')
L=len(n)
x=len(n)-1
for i in range (-L,0):
p=n[i]
final=final+(int(p))*(2**x)
x=x-1
print 'total=',finalEdit: Also, looking and running your code, you use functions I haven't really learned yet xD I hadn't seen enumerate yet, or the way you reversed the number, we do it more... stupidly because we're noobies at my class xD, also we've never used more than one variable in a 'for x in range', when we need more than one we do:
Code:
for x in range (y,z):
for j in range(p,q):
something something
