Advertisement
immanual1

numberofdigit.py

Jan 13th, 2025
13
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.21 KB | None | 0 0
  1. def count_digits(n):
  2. count = 0
  3. while n != 0:
  4. n //= 10
  5. count += 1
  6. return count
  7.  
  8. num = int(input("Enter a number: "))
  9. digits = count_digits(num)
  10. print("Number of digits:", digits)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement