Question: Write a Python code to read data from the below text file and store the costs into a dictionary called 'costs'. The item on the

Write a Python code to read data from the below text file and store the costs into a dictionary called 'costs'. The item on the left is the key and the amount of costs on the right is the value. If the item appears several times, sum them together. If the amount is empty or zero, don't add this item into the dictionary.

Write a Python code to read data from the below text file

Example output:

costs = {'breakfast': 3.55, 'bus': 5.5, 'coffee': 6.95, 'lunch': 19.95, 'dinner': 25.55}

breakfast: 3.55 newspaper: bus: 2.75 : coffee: 4.5 lunch: 19.95 coffee: 2.45 fruits: 0 bus: 2.75 dinner: 25.55

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!