Question: Hi, I am very new to Python Programming. I have just finished part 1 of this problem. However, I am stuck at part 2. I
Hi,
I am very new to Python Programming. I have just finished part 1 of this problem. However, I am stuck at part 2. I am having hard time trying to figure out how to print out error message and stop the program whenever the current average price is lower than the previous one. Could you please give me a suggestion for part 2? I have tried while loop but it did not work. Thank you!

Before the drone can take-off, it is required to do the following in ASCENDING order by price: . 1) Calculate and print the average price of an item at each store. . All monetary values will be positive & must be printed with two decimal places. . 2) Verify that the average price of the previous store is less than the current store. o If any store is out of order, the drone cannot take off, and the program should print an error message. See Example 2. Example 1: stores = [Store (name='Albertsons', inventory={ 'Chips': [5.00, 10], 'Pizza': [12.00, 3]}), Store (name='99-Cent Store', inventory={ 'Salsa': [1.00, 1]]) ] should produce: The average item at 99-Cent Store costs $1.00 The average item at Albertsons costs $6. 62 Note: (5.0 * 10) + (12.0 * 3) 10 + 3 ~6.62 Example 2: stores = [Store (name='Vons', inventory={ 'Cereal': [10.00, 10]}), Store (name= 'Albertsons' , inventory={ 'Chips': [5.00, 10], 'Pizza': [12.00, 3]}), Store (name= '99-Cent Store', inventory={ 'Salsa': [1000.00, 1]}) ]) should produce: The average item at 99-Cent Store costs $1000.00 The average item at Albertsons costs $6. 62 Error: Outdated information, quitting program
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
