Modify Program Read Dictionary Items File Write Inverted Dictionary File Need Decide Follo Q43820637
Modify your this program to read dictionary itemsfrom a file and write the inverted dictionary to a file. You willneed to decide on the following:
def invert_dict(d):
inverse = dict()
for key in d:
val = d[key]
if val not in inverse:
inverse[val] = [key]
else:
inverse[val].append(key)
return inverse
- How to format each dictionary item as a text string in theinput file.
- How to covert each input string into a dictionary item.
- How to format each item of your inverted dictionary as a textstring in the output file.
Include the following in your Learning Journal submission:
- The input file for your original dictionary (with at least sixitems).
- The Python program to read from a file, invert the dictionary,and write to a different file.
- The output file for your inverted dictionary.
- A description of how you chose to encode the originaldictionary and the inverted dictionary in text files
Expert Answer
Answer to Modify your this program to read dictionary items from a file and write the inverted dictionary to a file. You will need…
OR