[Tutor] Re: Soem list operation questions?

Roel Schroeven rschroev_nospam_ml at fastmail.fm
Tue Dec 28 17:47:23 CET 2004


Orri Ganel wrote:
> 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



More information about the Tutor mailing list