71.2k views
2 votes
You work for a shipping company and your manager receives orders from various customers everyday some existing ,some new .your manager wishes to establish a process to automate tracking the orders received by the company .you can assume the daily data arrives as lists/array/vector of strings and follows this exact format(note that customers may place separate orders in a single day):

day_i=["Bob:100","Alice:100","Celia:110","Bob:20",etc.]
write a script that, when given the daily data will keep track of purchase amount for each customer. you can assume the data already exists in the memory

User Ilgam
by
3.9k points

1 Answer

3 votes

Answer:

It's good to consider this as a dictionary, with key-value pair, or as a two-dimensional array.

And in the first case, the code will be as below:

day_i={'Bob':'100', 'Alice':'100','Celia':'110','Bob':'200'}

for k, v in day_i.items():

print(k, v)

Step-by-step explanation:

The above code reads through each day, and each customer purchase amount in the form of Dictionary, and prints each customer name and purchase amount. And with little enhancement, we can create each day data, and print details of the day, as being asked by the user.

User NET Experts
by
4.1k points