Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #makes a input variable equal to a integer that the user inputs
- Input = int(input("Please enter a integer:"))
- #sets the counter for the digits equal to 0
- counter = 0
- #makes a loop while the inputted value is greater or equal to 1
- while (Input >= 1):
- #divides the input value by 10 to move the decimal place over one
- Input = Input / 10
- #adds 1 to the counter variable since the decimal moved over before the input
- #variable reached 1 or under 1 meaning there is another digit in the integer
- counter = counter + 1
- #outputs the final counter for how many digits are in the integer
- print("The total amount of digits in this integer is", counter)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement