Ask Question
27 August, 12:39

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:

+1
Answers (1)
  1. 27 August, 14:04
    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?
Get 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 there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers