Ask Question
22 February, 13:04

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:

+2
Answers (1)
  1. 22 February, 13:06
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers