"A.T.Hofkamp" <[email protected]> wrote
If you reverse the computation, it gets even simpler:
binstr = raw_input("Please enter a binary number: ")
decnum = 0
for i in binstr:
decnum = decnum * 2 + int(i)
But if we are allowed to use int() it is easier still:
decnum = int(raw_input("Please enter a binary number"), 2)
Since int() now converts binary strings to decimal...
:-)
Alan G.
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor