Question: Could someone fix this for me? Write a function, called update_dictionary that has two parameters: a filename and a dictionary. The function should 1. Open

Could someone fix this for me?

Could someone fix this for me? Write a function, called update_dictionary that

has two parameters: a filename and a dictionary. The function should 1.

Write a function, called update_dictionary that has two parameters: a filename and a dictionary. The function should 1. Open the given file 1. If the file open succeeds print "filename loaded successfully. 2?lf the file open fails: print "filename does not exist." 2. Read in the data and fill the dictionary 3. Provide the new size: print "The dictionary has_entries." 4. Return the updated dictionary y:why, "18: late', 'r:'are, 'u: you) The dictionary key is the text abbreviation and the value is the English translation For example, one entry in your dictionary will be,'B': 1ate, because one of the rows in the Dt file contains 18' and 'late Test your function before moving on to the next question Answer: (penalty regime 0 %) ?| def 2 V 3r 4 update-dictionary(filename,d):1 try: with open(filename, 'r)as f: print(filename loaded successfully.') for line in f: words-line.strip).split(',') d[words[]]-words[1] 7 print('The dictionary hasstr(len(d.items)))+ entries.') except: print('invalid file.txt does not exist.') print( 'The dictionary has entries.') 12 13 14 Check

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!