Python (Writing list items to a text file)
You need to create a file of inventory_items which has the following items. Use a loop to read in each value until exit is entered for the item_name. This input represents the item_name,number_sold, price_item, and cost_item.
Blue Pens
400
1.39
0.75
No. 2 Pencils
1000
0.25
0.1
Notebooks
500
6.99
3.47
For each item entered, create a string with the values separated by commas. One item is shown as an example.
Blue Pens, 400, 1.39, 0.75
Write out each item string to file named inventory_items.txt.
Read in the lines of text and split up string line into a list. Access the appropriate list elements in order to perform the following calculation for the profit: number_sold * (price_item - cost_item).
Print out the name of the item and the profit with two decimal places of precision.
Sum up the profit in order to compute the total profit.