Question: Below is the program from learning journal 7 input and also the output. Please help INPUT OUTPUT Modify your program from Learning Journal Unit 7

Below is the program from learning journal 7 input and also theBelow is the program from learning journal 7 input and also the output. Please help

INPUT

output. Please help INPUT OUTPUT Modify your program from Learning Journal Unit

OUTPUT

7 to read dictionary items from a file and write the inverted

Modify your program from Learning Journal Unit 7 to read dictionary items from a file and write the inverted dictionary to a file. You will need to decide on the following: How to format each dictionary item as a text string in the input file. How to covert each input string into a dictionary item. How to format each item of your inverted dictionary as a text string in the output file. Create an input file with your original three-or-more items and add at least three new items, for a total of at least six items. Include the following in your Learning Journal submission: The input file for your original dictionary (with at least six items). 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 original dictionary and the inverted dictionary in text files. . # name : [animal type, age, sex] animal_shellter { "Teddy": ["dog", 4, "male"], "Elvis": ["dog",1, "male"), "Sheyla": ["dog",5,"female"], "Topic": ["hamster", 3, "male"], "Kuzya": ["cat", 10, "male"], "Misi": ["cat",8,"female"], } 10 print(animal_shellter) print("") 14 def invert(d): inverse = dict() for key in d: val = d[key] 207 for item in val: if item not in inverse: inverse[item] = [key] else: inverse[item].append(key) return inverse inverted_shellter - invert(animal_shellter) print(inverted_shellter) Python Interpreter *** Python 3.9.0 (tags/v3.9.0:9cf6752, Oct 5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32. *** *** Remote Python engine is active *** >>> *** Remote Interpreter Reinitialized *** {'Teddy': ['dog', 4, 'male'), 'Elvis': ['dog', 1, 'male'], 'Sheyla': ['dog', 5, 'female'], 'Topic': ["hamster', 3, 'male'], "Kuzya': ['cat', 10, 'male'], "Misi': ['cat', 8, 'female']} {'dog': ['Teddy', 'Elvis', 'Sheyla'), 4: ['Teddy'), 'male': [ 'Teddy', 'Elvis', 'Topic', 'Kuzya'), 1: ['Elvis'], 5: ["Sheyla'), 'female': [ 'Sheyla', "Misi'], "hamster': ['Topic'), 3: ['Topic'), 'cat': ['Kuzya', Misi'], 10: ['Kuzya'], 8: ["Misi']} >>>

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!