Fastest way to loop through each digit in a number?

Paul Rubin http
Mon Sep 6 05:27:18 CEST 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