Fastest way to loop through each digit in a number?

Paul Rubin http
Sun Sep 5 23:27:18 EDT 2004


Rune Strand <rst at _nospam_.drlug.org._nospam_> writes:
You could try timing something like

  while n:
    n,d = divmod(n, 10)
    foo(d)

That processes the digits in reverse order, of course.



More information about the Python-list mailing list