On Tue, Feb 3, 2009 at 10:17 AM, H.G. le Roy <[email protected]> wrote:
> One step for my solution should be transforming this big integer to a list > of integers. I did: > > import math > > bignr = 12345 > bignrs =[] > The suggestions with strings are fine, but you can simplify your approach as well: > for i in xrange(math.ceil(math.log10(bignr)): No need for the complicated range expression, just use while bignr > 0: > rem = bignr % 10 > bignrs.append(rem) > bignr /= 10 Using the divmod() function you can compute rem and the new value for bignr in one operation: bignr, rem = divmod(bignr, 10) Kent _______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
