0
0
Pythonprogramming~15 mins

Adding and removing list elements in Python - Mini Project: Build & Apply

Choose your learning style9 modes available
Adding and removing list elements
๐Ÿ“– Scenario: You are managing a simple to-do list for daily tasks. You want to add new tasks and remove completed ones from your list.
๐ŸŽฏ Goal: Build a small program that starts with a list of tasks, adds a new task, removes a completed task, and then shows the updated list.
๐Ÿ“‹ What You'll Learn
Create a list called tasks with three specific tasks
Create a variable called new_task with a task to add
Add the new_task to the tasks list
Remove a specific task from the tasks list
Print the final tasks list
๐Ÿ’ก Why This Matters
๐ŸŒ Real World
Managing lists of tasks, shopping items, or any collection of things is common in daily life and software.
๐Ÿ’ผ Career
Knowing how to add and remove items from lists is a basic skill for programming jobs involving data handling and user input.
Progress0 / 4 steps
1
Create the initial list of tasks
Create a list called tasks with these exact strings: 'Buy groceries', 'Clean the house', and 'Pay bills'.
Python
Need a hint?

Use square brackets [] to create a list and separate items with commas.

2
Add a new task to the list
Create a variable called new_task and set it to the string 'Walk the dog'.
Python
Need a hint?

Use the equals sign = to assign the string to the variable.

3
Add the new task and remove a completed task
Add the new_task to the tasks list using the append() method. Then remove the task 'Clean the house' from the tasks list using the remove() method.
Python
Need a hint?

Use list.append(item) to add and list.remove(item) to remove an item.

4
Print the updated list
Print the tasks list to show the updated tasks.
Python
Need a hint?

Use the print() function to display the list.