Ask Question
28 May, 04:45

Write a function named initialMatch that takes a string parameter, text, that contains only lowercase letters and whitespace. The function initialMatch should return a dictionary in which each word in text is a key. The value of each key should be a list of all words in text that satisfy the following three conditions: 1. all words in the list should have the same initial letter as the key 2. no word in the list should appear more than once 3. the key shouldn't be in the list For example, the following would be correct input and output:

+4
Answers (1)
  1. 28 May, 08:10
    0
    Implementing on Python for the question, the following is the code.

    Explanation:

    def intialMatch (l):

    word_dict={}

    for word in l. split ():

    if word_dict. get (word) = =None:

    word_dict[word]=[]

    for key in word_dict. keys ():

    if key[0]==word[0] and (word is not key):

    values = word_dict. get (key)

    if word not in values:

    values. append (word)

    for key, values in word_dict. items ():

    for value in values:

    if value==key:values. remove (value)

    return word_dict

    t='do what you can with what you have'

    print (intialMatch (t))
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write a function named initialMatch that takes a string parameter, text, that contains only lowercase letters and whitespace. The function ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers