Write a function count_digits (s) that counts the number of digits in the string s and returns
answer (an integer).
This function is internally using a for loop(in Python language, and keep it as simple as possible) please
1
Expert's answer
2012-03-30T11:26:54-0400
def count_digits (s): cnt=0 for i in range(len(s)): if (s[i]>='0') and (s[i]<='9'): cnt=cnt+1 return cnt
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
Finding a professional expert in "partial differential equations" in the advanced level is difficult.
You can find this expert in "Assignmentexpert.com" with confidence.
Exceptional experts! I appreciate your help. God bless you!
Comments
def count_digits(s): swithoutdigits = s.translate(None, '1234567890') digitcount = len(s) - len(swithoutdigits) return digitcount
Leave a comment