- This event has passed.
6 PM – Python OOP – Darin
July 16, 2024 @ 6:00 pm - 7:00 pm
What We Did Today:
- Finished Library
Homework:
Continue working on SupermarketApplication and do the following:
- Add print statements using item.name and item.price in each of the if statements.
- Outside the while loop, use a for loop to print each items name (you have to consider how to get the names of each item in the list)
Refer to the comments below:
def application_loop(self):
while True:
selection = input(self.menu)
if selection == "1":
item = self.menu_items["1"]
self.shopping_cart.append(item)
# print "you bought {name} for {price}"
elif selection == "2":
item = self.menu_items["2"]
self.shopping_cart.append(item)
elif selection == "3":
item = self.menu_items["3"]
self.shopping_cart.append(item)
elif selection == "4":
break
# right here outide the while loop
# use a for loop to print the items in the shopping_cart list
Notes:
If you have any questions, you can contact me at ddjapri@ayclogic.com