+ 1
How to count the digits of a number that starts with zero ?
I want to count the digits of a number like ( 010 ) in python. How should I do that?
3 Answers
+ 7
Nikki
#to get the number of digits e.g. '010' can be done like:
str_num = input()
if str_num.isdigit(): # check if the string contains only digits:
print(len(str_num)) # get the number of digits:
+ 8
Nikki ,
for your example '010', do want to count the leading zero or not?
0
Lothar ,
I want to count the zero too .