Hey there, I am working to create a program and the answers I found here is not complete. When I run it doesn't give me the right out put even if I edited. Here is one question for example: # Create a program, digits.py, that has a function that takes a number and prints the number of digits in the number. It should work for numbers with decimals, too. The first part I got it, but it doesn't work for the digit part. Here is my code after editing: import sys def numDigits(): n = int(input('Enter number:')) count = 0 while n > 0: count = count + 1 n = n // 10 print('The number of digits in the number are:', count) numDigits() let me get your important hints. Thanks in advance!
Hey there, I am working to create a
# Create a program, digits.py, that has a function that takes a number and prints the number of digits in the number. It should work for numbers with decimals, too.
The first part I got it, but it doesn't work for the digit part.
Here is my code after editing:
import sys
def numDigits():
n = int(input('Enter number:'))
count = 0
while n > 0:
count = count + 1
n = n // 10
print('The number of digits in the number are:', count)
numDigits()
let me get your important hints. Thanks in advance!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images