Not an expert here, but I think I would first change it to a big string of 1000 chars and then pick off the chars one at a time and do int().


-----Original Message-----
From: "H.G. le Roy"
Sent: Feb 3, 2009 10:17 AM
To: [email protected]
Subject: [Tutor] transforming an integer to a list of integers

Hi,

recently I learned about Project Euler (http://projecteuler.net/) and now I'm trying to work me through. At the moment I'm thinking about http://projecteuler.net/index.php?section=problems&id=8

One step for my solution should be transforming this big integer to a list of integers. I did:

import math

bignr = 12345
bignrs =[]

for i in xrange(math.ceil(math.log10(bignr)):
  rem = bignr % 10
  bignrs.append(rem)
  bignr /= 10

However this "feels" a bit complicated, Do you know a better (more simple, nice etc.) way to do this?

Thanks
_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to