Home/Support/Support Forum/python program to count the number of digits in following way as given in description
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

python program to count the number of digits in following way as given in description

0 votes
write a python program to count the number of digits given as input.
for example,
if i give input as "1 2 3 4 5 6" output will be "6"
and when i give input as"1 2 3 4 5 6 7 8 9 10" then the output returned should be like,"1 to 9 it is 9 digits.10 has 2 digits 1 and 0 so the total number of digits is 9+2=11"

try and solve the question as soon as possible.
asked Dec 2, 2016 in 3rd Party Python and API development in other Languages by SAP_PYTHON New to the Community (0 points)

Please log in or register to answer this question.

1 Answer

+1 vote
>>> data = "1 2 3 4 5 6"
>>> data1 = "1 2 3 4 5 6 7 8 9 10"
>>> sum(map(lambda x: x in '0123456789', data))
6
>>> sum(map(lambda x: x in '0123456789', data1))
11
answered Dec 5, 2016 by NicholasWilson Veteran of the Digi Community (1,001 points)
...