Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Database Modeling With Neo4j

Authors: Ajit Singh

2nd Edition

B0BDWT2XLR, 979-8351798783

More Books

Students also viewed these Databases questions