Question: Write a function in python defcount_starts(text): Consider text representing a list of strings. The function should check the starting character of each string in the

Write a function in python defcount_starts(text): Consider text representing a list of strings. The function should check the starting character of each string in the list, construct and return a dictionary that uses the leading characters of each string in text as keys and an integer number as their values to report how many strings start with that character.

o text: a list of non-empty strings; text can be empty.

o Return value: a dictionary reporting the occurrences of leading characters in the list of

strings.

Examples:

o count_starts(['time','after','time']) {'t': 2, 'a': 1}

o count_starts(["a","b","r","a","c","a","d","a","b","r","a") {'r': 2, 'd': 1, 'c': 1, 'b': 2, 'a': 5}

o count_starts([]) {}

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 Databases Questions!