I have a dictionary self.total = defaultdict(int)
in my Order class that is used to input and print totals of every item that is ordered in my ordering system. Object are stored as
coffee_available=[Coffee(1, "1: Flat White", 3.50),
Coffee(2, "2: Long Black", 3.50),
Coffee(3, "3: Cappuccino", 4.00),
Coffee(4, "4: Espresso", 3.25),
Coffee(5, "5: Latte", 3.50)]
`
and the way I "order" these objects is by calling a function in my order class
def order(self, order_amount, coffee_id):
self.total[coffee_id] += order_amount
and i print each item type and their respective order amounts by using another function in my order class
def print_order(self):
print(" ")
print("Coffee Type\t\tAmount of Times ordered")
print("-----------\t\t-----------------------")
for coffee in coffee_available:
print("{}\t- - -\t {} ".format(coffee.coffee_type, self.total[coffee.coffee_id]))
this works well as each time my code is run in the same session it stores the order_amount
value each time and displays it correctly, the only problem is that if i terminate the program it doesn't store the data for when i open it next. If I were to permanently store data how would I do it and what should i permanently store?