On 04/05/13 05:13, Jim Mooney wrote:
I'm turning an integer into a string so I can make a list of separate
chars, then turn those chars back into individual ints,

You don't actually need to convert to chars, you could
use divmod to do it directly on the numbers:

>>> digits = []
>>> root = 455
>>> while root > 0:
...     root, n = divmod(root,10)
...     digits.insert(0,n)
...
>>> digits
[4, 5, 5]

But I suspect the str() method is slightly faster...

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to