Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: List Management | Other Data Types
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Introduction to Python

bookChallenge: 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.

Task

Swipe to start coding

Work with a small deli department list by combining items, making one simple update, and sorting the final result.

  1. 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".
  2. Create Main List:

    • Combine meat and cheese into a single list called deli_dept.
  3. Restock Ham:

    • If the quantity of "Ham" is less than 100, update it to 100.
  4. Sort List:

    • Sort deli_dept alphabetically based on the first element of each sublist using the sort() method.

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>".

Solution

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 4. ChapterΒ 4
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

close

bookChallenge: 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.

Task

Swipe to start coding

Work with a small deli department list by combining items, making one simple update, and sorting the final result.

  1. 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".
  2. Create Main List:

    • Combine meat and cheese into a single list called deli_dept.
  3. Restock Ham:

    • If the quantity of "Ham" is less than 100, update it to 100.
  4. Sort List:

    • Sort deli_dept alphabetically based on the first element of each sublist using the sort() method.

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>".

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 4. ChapterΒ 4
single

single

some-alt