Python Program Count the Number of Digit in a Number
number = int(input("Enter a number: "))
count = 0
if number == 0:
count = 1
else:
if number < 0:
number = -number
while number > 0:
count += 1
number //= 10
print(f"The number of digits is {count}.")
#source code --> clcoding.com
0 Comments:
Post a Comment