Fastest way to loop through each digit in a number?
Terry Reedy
tjreedy at udel.edu
Mon Sep 6 02:32:46 EDT 2004
"Rune Strand" <rst at _nospam_.drlug.org._nospam_> wrote in message
news:ssjnj01agata9qtsn414740sml1kc2em49 at 4ax.com...
> Hi,
> If I have a lot of integers and want do something with each digit as
> integer, what is the fastest way to get there?
>
> Eg. Make 12345 into an iterable object, like [1,2,3,4,5] or "12345"
>
> (Btw: What is the English term for this process; itemize? tokenize?
> digitize? sequence?)
>
> Some examples:
You might also look at
zero = ord('0')
and then ord(i)-zero in loop
tjr
More information about the Python-list
mailing list