Advertisement
Guest User

Untitled

a guest
Sep 17th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. #makes a input variable equal to a integer that the user inputs
  2. Input = int(input("Please enter a integer:"))
  3.  
  4. #sets the counter for the digits equal to 0
  5. counter = 0
  6.  
  7. #makes a loop while the inputted value is greater or equal to 1
  8. while (Input >= 1):
  9.  
  10.     #divides the input value by 10 to move the decimal place over one
  11.     Input = Input / 10
  12.  
  13.     #adds 1 to the counter variable since the decimal moved over before the input
  14.     #variable reached 1 or under 1 meaning there is another digit in the integer
  15.     counter = counter + 1
  16.  
  17. #outputs the final counter for how many digits are in the integer
  18. print("The total amount of digits in this integer is", counter)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement