1n = 1234 //Any Random Number
2digits = len(str(n)) //Saves the number of digits of n into the variable digits
1# Below uses constant space (converting to string and then gettings it's length does not)
2num = 12362
3count = 0
4while num > 0:
5 count += 1
6 num = num // 10
7print(count)
8
9# for negative numbers, take absolue value first:
10num = -12362
11num = abs(num)
12count = 0
13while num > 0:
14 count += 1
15 num = num // 10
16print(count)