Though, of course, by modifying your way (using str() ), it will still work:
def listtoint(digits):
result = 0
for digit in digits:
result *= (10**len(str(digit))) ## just multiply it by 10 result += digit ## to the power of the number of digits
return result
That's much more robust indeed. I was trying to make it as simple as possible; perhaps I made it a bit too simple.
-- "Codito ergo sum" Roel Schroeven
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor