In: Computer Science
Python Language - Cant seem to get the correct output. Also, need through explanation if possible. much appreciative
| 
 XXXXX PYTHON>>>>>>>>> Write a function named shareOneLetter that takes one parameter, wordList a list of words. Create 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 For example, the following is correct
output:  | 
Source Code:
def ShareOneLetter(wordList):
   myDict={}
   for item in wordList: # for each word in
wordList
       temp=[] # take an empty list to add
items of word List which are matched
       for ch in item: # check for each
charcter in item what are the matching words
           for ele in
wordList: # this loop checks for all match words for the letter
ch
          
    if (ch in ele) and (ele not in temp): # if the
letter is matched in item and item not already present
          
        temp.append(ele) # append to
temp
       myDict[item]=temp # append the list
of items matched
   return myDict # return the dictionary
horton=['I','say','what','mean','and']
print(ShareOneLetter(horton))
Sample input and output:
