Function named wordcount that takes one parameter wordlist


Problem 1. Function named wordCount that takes one parameter, wordList -- a list of words and return a dictionary in which each word in wordList is a key and the corresponding value is the number of times in wordList that word appears.

For example, the following is correct output

horton = ['I','say','what','I','mean','and','I','mean','what','I','say']

print(wordCount(horton))

{'I': 4, 'say': 2, 'what': 2, 'mean': 2, 'and': 1}

Problem 2. function named initialLetters that takes one parameter, wordList -- a list of words and return a dictionary in which each initial letter of a word in wordList is a key and the corresponding value is a list of the words in wordList that begin with that letter. There should be no duplicate words in any value in the dictionary.

For example, the following is correct output

print(initialLetters(horton))

{'i': ['I'], 's': ['say'], 'w': ['what'], 'm': ['mean'], 'a': ['and']}

Problem 3. function named shareALetter that takes one parameter, wordList -- a list of words and return a dictionary in which each word in wordList is a key and the corresponding value is a list of all the words in wordList that share at least one letter with that word. There should be no duplicate words in any value in the dictionary.

For example, the following is correct output

print(shareALetter(horton))

{'I': ['I'], 'say': ['say', 'what', 'mean', 'and'], 'what': ['say', 'what', 'mean', 'and'], 'mean': ['say', 'what', 'mean', 'and'], 'and': ['say', 'what', 'mean', 'and']}

Solution Preview :

Prepared by a verified Expert
Business Management: Function named wordcount that takes one parameter wordlist
Reference No:- TGS02518988

Now Priced at $10 (50% Discount)

Recommended (96%)

Rated (4.8/5)