Do a zero check before you enter the loop: if it's zero, return one immediately.
Alternatively, use logarithms to get the digits count:
import math
def counter(num):
if (num == 0):
return 1
return int(math.log10(num)) + 1
print(counter(0))
print(counter(1))
print(counter(12))
print(counter(123))
print(counter(1234))
print(counter(12345))
print(counter(123456))
print(counter(1234567))