Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

sample text file what i have so far def CreateDictionary(filename): dictionary =

ID: 3776988 • Letter: S

Question

sample text file

what i have so far

def CreateDictionary(filename):
   dictionary = {}
   myfile = open(filename, "r")
  
   for line in myfile.read().splitlines():
       data = line.split(",")
       key = data[0]
       value = data[1]
         
       dictionary[key] = value
      
   return dictionary

def DeSlang(slang, wordDictionary):
   output = " "
   for item in slang:
   # if item is a key of wordDictionary then get value of that key and add to output
       if item in wordDictionary.keys():
           output += wordDictionary[item]
       else:
           output += item
   output = output + " "
   return output
            
  
def main():
   wordDictionary = CreateDictionary("textToEnglish.txt")
   userinput = raw_input("Please a sentence you wish to deslang: ").split(" ")
  
   print DeSlang(userinput, wordDictionary)
if __name__ == "__main__":
   main()

please help part 3. I have part 1 and two done on here. also when i run my code and input "u r 1daful" for example

output : youarewonderful

i dont know how to put spaces between the words for output. help please

3. Your main function in the py file containing your functions, CreateDictionary, and Deslang, should do the following: a. Call the CreateDictionary function. b. Prompt the user for a text abbreviation and check if it is in the dictionary. If it is, print the English words associated with the abbreviation, otherwise print "Not Found". Your main must also allow the user to continue inputting abbreviations and printing the English meaning of those abbreviations until the user enters "quit". c. Prompt the user for an arbitrary number of text abbreviations, separated by a space, and print a string that displays the meaning of all abbreviations (by calling the Deslang function). Your main must also allow the user to continue inputting sentences with abbreviations and printing the English meaning of those sentences without abbreviations until the user enters "quit".

Explanation / Answer

def CreateDictionary(filename): dictionary = {} myfile = open(filename, "r") for line in myfile.read().splitlines(): data = line.split(",") key = data[0] value = data[1] dictionary[key] = value return dictionary def DeSlang(slang, wordDictionary): output = " " for item in slang: # if item is a key of wordDictionary then get value of that key and add to output if item in wordDictionary.keys(): output += " "+wordDictionary[item] else: output += item output = output + " " return output def main(): wordDictionary = CreateDictionary("textToEnglish.txt") flag="" while flag!="quit": userinput = raw_input("Please a sentence you wish to deslang: ") flag = userinput userinput=userinput.split(" ") print DeSlang(userinput, wordDictionary).strip() if __name__ == "__main__": main()