Question: Write a function called letter_count that has two strings as parameters. The function examines its first parameter, counting certain letters; the second parameter is a
Write a function called letter_count that has two strings as parameters. The function examines its first parameter, counting certain letters; the second parameter is a string that specifies which letters to count. Thus, letter_count(some_message, 'aeiou') would return counts of the vowels in the string some_message and letter_count(some_message, ' \t ') would return counts of the white-space characters (space, tab, and newline). The function should return its counts as a list of Count namedtuples, where a Count namedtuple has two fields, letter and number. [Okay; go back and read that again, two or three times, until it's clear. It's important to be able to read specifications that use technical terminology. The following example may also help.] Calling letter_count('The cabbage has baggage', 'abcd') should return [Count(letter='a',number=5), Count(letter='b',number=3), Count(letter='c',number=1), Count(letter='d',number=0)].
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
