count number of digits in a number python using for loop code example Example: python count number of digits in integer import math digits = int(math.log10(n))+1