Challenge: Sales and Shipments
In this challenge, you'll manage the daily stock levels of essential grocery store products over a week. By utilizing the range() function in conjunction with the len() function, you'll simulate sales impacts on inventory.
Swipe to start coding
Update the stock levels using one loop.
-
Use a
forloop with index iteration (range) to go throughproducts. -
For each product, subtract the sold amount from units_sold using the same index:
products[i][1] = products[i][1] - units_sold[i]
At the end, print exactly:
Final stock levels: <products>
Expected final products:
[['Apples', 7], ['Bananas', 3]]
Solution
Thanks for your feedback!
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Awesome!
Completion rate improved to 1.89
Challenge: Sales and Shipments
Swipe to show menu
In this challenge, you'll manage the daily stock levels of essential grocery store products over a week. By utilizing the range() function in conjunction with the len() function, you'll simulate sales impacts on inventory.
Swipe to start coding
Update the stock levels using one loop.
-
Use a
forloop with index iteration (range) to go throughproducts. -
For each product, subtract the sold amount from units_sold using the same index:
products[i][1] = products[i][1] - units_sold[i]
At the end, print exactly:
Final stock levels: <products>
Expected final products:
[['Apples', 7], ['Bananas', 3]]
Solution
Thanks for your feedback!
single