[Tutor] Re: Soem list operation questions?

Orri Ganel singingxduck at gmail.com
Tue Dec 28 17:18:56 CET 2004


Yes, but your way only works when the numbers in the list are single digit:

>>> def listtoint(digits):
    result = 0
    for digit in digits:
        result *= 10
        result += digit
    return result

>>> listtoint([1,2,3,4])
1234
>>> listtoint([11,22,33,44])
13574

-- 
Email: singingxduck AT gmail DOT com
AIM: singingxduck
Programming Python for the fun of it.


More information about the Tutor mailing list