Question: expected output I got here is my code def update_dictionary(filename, d): try: with open(filename, 'r') as f: print(filename + ' loaded successfully.') for line in

expected output

I got
![line in f: words = line.strip().split(",") d[words[0]] = words[1] except: print(filename +](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f3005987471_36966f3005921f24.jpg)
here is my code
def update_dictionary(filename, d): try: with open(filename, 'r') as f: print(filename + ' loaded successfully.') for line in f: words = line.strip().split(",") d[words[0]] = words[1] except: print(filename + ' does not exist.') print('The dictionary has ' + str(len(d.items())) + ' entries.') return d
def deslang(slang, d): deslanged = [] for word in slang.split(): if word in d: deslanged.append(d[word]) else: deslanged.append(word) return ' '.join(deslanged)
def main(): words = {} userInput = input('Would you like to (a)dd words to the dictionary, (d)e-slang a sentence, or (q)uit?: ') while (userInput != 'q'): if userInput == 'a': file_name = input("Enter a filename: ") update_dictionary(file_name, words) if userInput == 'd': sentence = input('Enter a sentence: ') while sentence.strip() == '': sentence = input('Enter a sentence: ') sentence = deslang(sentence, words) print(sentence) if userInput != 'q': userInput = input('Would you like to (a)dd words to the dictionary, (d)e-slang a sentence, or (q)uit?: ')
main()
tell me how to modify only the main function ,thanks!!
Your main function in the py file containing your functions, update_dictionary, and deslang, should provide the following menu: Would you like to (a)dd words to the dictionary, (d)e-slang a sentence, or (q)uit? For this assignment, will be testing your code by running your entire file (as we did in Homework 7). Please reference the following sample runs for your menu functionality: Would you like to (aldd words to the dictionary, (d)e-slang a sentence, or (q)uit?: a Enter a filename: textToEnglish.txt textToEnglish.txt loaded successfully. The dictionary has 4239 entries. Would you like to (a)dd words to the dictionary, (dje-slang a sentence, or (quit?: d Enter a sentence: Enter a sentence: Enter a sentence: David, yr u l8 David, why are you late Would you like to (a)dd words to the dictionary, (d)e-slang a sentence, or (q)uit?: q Copy your solution to the previous questions(Q1 and Q2) here
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
