Challenge: List Management
Are you ready to apply your new knowledge of lists and list methods in a practical setting?
This challenge will engage you in managing a grocery store's deli department items, requiring you to utilize nested lists, list methods, and conditional logic.
Swipe to start coding
Work with a small deli department list by combining items, making one simple update, and sorting the final result.
-
Initialize Lists:
- Create a list
meatwith the values:"Ham",3.99,50,"Sliced"; - Create a list
cheesewith the values:"Cheddar",5.49,100,"Sharp".
- Create a list
-
Create Main List:
- Combine
meatandcheeseinto a single list calleddeli_dept.
- Combine
-
Restock Ham:
- If the quantity of
"Ham"is less than100, update it to100.
- If the quantity of
-
Sort List:
- Sort
deli_deptalphabetically based on the first element of each sublist using thesort()method.
- Sort
Output Requirements
- Print the initial state of
deli_deptwith the message:"Initial Deli List: <deli_dept>". - After all operations, print the updated state of
deli_deptwith the message:"Updated Deli List: <deli_dept>".
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: List Management
Swipe to show menu
Are you ready to apply your new knowledge of lists and list methods in a practical setting?
This challenge will engage you in managing a grocery store's deli department items, requiring you to utilize nested lists, list methods, and conditional logic.
Swipe to start coding
Work with a small deli department list by combining items, making one simple update, and sorting the final result.
-
Initialize Lists:
- Create a list
meatwith the values:"Ham",3.99,50,"Sliced"; - Create a list
cheesewith the values:"Cheddar",5.49,100,"Sharp".
- Create a list
-
Create Main List:
- Combine
meatandcheeseinto a single list calleddeli_dept.
- Combine
-
Restock Ham:
- If the quantity of
"Ham"is less than100, update it to100.
- If the quantity of
-
Sort List:
- Sort
deli_deptalphabetically based on the first element of each sublist using thesort()method.
- Sort
Output Requirements
- Print the initial state of
deli_deptwith the message:"Initial Deli List: <deli_dept>". - After all operations, print the updated state of
deli_deptwith the message:"Updated Deli List: <deli_dept>".
Solution
Thanks for your feedback!
single