"A.T.Hofkamp" <a.t.hofk...@tue.nl> 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 - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor