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
Manage a list of deli items by initializing, updating, and organizing them across different categories such as meats, cheeses, and condiments.
-
Initialize Lists:
- Create a list
meat
with the values:"Ham"
,3.99
,50
,"Sliced"
; - Create a list
cheese
with the values:"Cheddar"
,5.49
,100
,"Sharp"
; - Create a list
condiment
with the values:"Mustard"
,1.99
,75
,"Spicy"
.
- Create a list
-
Create Main List:
- Combine
meat
,cheese
, andcondiment
lists into a single list calleddeli_dept
.
- Combine
-
Restock Item:
- If
"Ham"
is in themeat
list and its quantity is less than100
, update its quantity to100
.
- If
-
Add Seasonal Meat:
- Create a list
seasonal_meat
with the values:"Turkey"
,4.50
,100
,"Sliced"
; - Append
seasonal_meat
todeli_dept
.
- Create a list
-
Remove Condiment:
- Remove the
condiment
list fromdeli_dept
.
- Remove the
-
Sort List:
- Sort
deli_dept
alphabetically based on the first element of each sublist.
- Sort
Output Requirements
- Print the initial state of
deli_dept
with the message:"Initial Deli List: <$deli_dept>"
. - After all operations, print the updated state of
deli_dept
with the message:"Updated Deli List: <$deli_dept>"
.
Note
Sorting the list will be based on the first value of each sublist (e.g.,
"Ham"
,"Cheddar"
,"Turkey"
).
Løsning
Takk for tilbakemeldingene dine!
single
Spør AI
Spør AI
Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår
Oppsummer dette kapittelet
Explain code
Explain why doesn't solve task
Awesome!
Completion rate improved to 2.17
Challenge: List Management
Sveip for å vise menyen
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
Manage a list of deli items by initializing, updating, and organizing them across different categories such as meats, cheeses, and condiments.
-
Initialize Lists:
- Create a list
meat
with the values:"Ham"
,3.99
,50
,"Sliced"
; - Create a list
cheese
with the values:"Cheddar"
,5.49
,100
,"Sharp"
; - Create a list
condiment
with the values:"Mustard"
,1.99
,75
,"Spicy"
.
- Create a list
-
Create Main List:
- Combine
meat
,cheese
, andcondiment
lists into a single list calleddeli_dept
.
- Combine
-
Restock Item:
- If
"Ham"
is in themeat
list and its quantity is less than100
, update its quantity to100
.
- If
-
Add Seasonal Meat:
- Create a list
seasonal_meat
with the values:"Turkey"
,4.50
,100
,"Sliced"
; - Append
seasonal_meat
todeli_dept
.
- Create a list
-
Remove Condiment:
- Remove the
condiment
list fromdeli_dept
.
- Remove the
-
Sort List:
- Sort
deli_dept
alphabetically based on the first element of each sublist.
- Sort
Output Requirements
- Print the initial state of
deli_dept
with the message:"Initial Deli List: <$deli_dept>"
. - After all operations, print the updated state of
deli_dept
with the message:"Updated Deli List: <$deli_dept>"
.
Note
Sorting the list will be based on the first value of each sublist (e.g.,
"Ham"
,"Cheddar"
,"Turkey"
).
Løsning
Takk for tilbakemeldingene dine!
Awesome!
Completion rate improved to 2.17single