Question: Write a function that counts the occurrences of each digit in a string using the following header: def count ( s ) : The function

Write a function that counts the occurrences of each digit in a string using the following header:
def count(s):
The function counts how many times a digit appears in the string. The return value is a list of ten elements, each of which holds the count for a digit. For example, after executing counts = count("12203AB3"), counts[0] is 1, counts[1] is 1,counts[2] is 2, and counts[3] is 2.Write a test program that prompts the user to enter a string and displays the number of occurrences of each digit in the string.
Sample run:
Enter a string: 2313138765
1 occurs 2 times
2 occurs 1 time
3 occurs 3 times
5 occurs 1 time
6 occurs 1 time
7 occurs 1 time
8 occurs 1 time

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!