3. The Last 'Zeroes'
How many zeroes are there after the last non-zero digit of a million? A trillion? To easily identify that, let us make a program to count and print the number of zeroes after the last non-zero digit on a number. For example, in 20400, there are 2 zeroes after the last non-zero digit of the number, 4.
Are you up for this challenge?
Input
A line containing an integer.
20400
Output
A line containing an integer.
2
def last_zeros(num):
new_num = str(num)
count = len(new_num) - len(new_num.rstrip("0"))
return count
N=int(input("Enter an interger: "))
print(last_zeros(N))
Comments
Leave a comment