import math
digits = int(math.log10(n))+1
num = 3452
count = 0
while num != 0:
num //= 10
count += 1
print("Number of digits: " + str(count))
n = 1234 //Any Random Number
digits = len(str(n)) //Saves the number of digits of n into the variable digits
# x: The int number
# n: Digit index
def digit_extraction_by_index(x, n):
return (abs(x) // (10 ** n)) % 10
print(digit_extraction_by_index(123, 0)) # 3
print(digit_extraction_by_index(123, 1)) # 2
number = str(input('enter number'))
i = 0
while i in range(len(number)):
i +=1
print(f'Number of digits: {i}')
num = 123456
print(len(str(num)))