Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Removing Elements | List
Python Data Structures
course content

Course Content

Python Data Structures

Python Data Structures

1. List
2. Dictionary
3. Tuple
4. Set
5. For deleting

bookRemoving Elements

Imagine you have this list:

12
tasks = ['email Ann', 'call Max', 'meet with classmates'] print(tasks)
copy

You can also remove an item from the list by specifying its value. Here's how to do that.

123
tasks = ['email Ann', 'call Max', 'meet with classmates'] tasks.remove('call Max') print(tasks)
copy

Now, the list is down to two items instead of three:

  • tasks[0] reads 'email Ann';
  • tasks[1] reads 'meet with classmates'.

Note

With the remove() method, you can only take out one item at a time.

Task

You've got this list:

numbers = [10, 12, 14, 16, 18, 20]

Your goal is to end up with:

numbers = [12, 14, 16]

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 1. Chapter 10
toggle bottom row

bookRemoving Elements

Imagine you have this list:

12
tasks = ['email Ann', 'call Max', 'meet with classmates'] print(tasks)
copy

You can also remove an item from the list by specifying its value. Here's how to do that.

123
tasks = ['email Ann', 'call Max', 'meet with classmates'] tasks.remove('call Max') print(tasks)
copy

Now, the list is down to two items instead of three:

  • tasks[0] reads 'email Ann';
  • tasks[1] reads 'meet with classmates'.

Note

With the remove() method, you can only take out one item at a time.

Task

You've got this list:

numbers = [10, 12, 14, 16, 18, 20]

Your goal is to end up with:

numbers = [12, 14, 16]

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 1. Chapter 10
toggle bottom row

bookRemoving Elements

Imagine you have this list:

12
tasks = ['email Ann', 'call Max', 'meet with classmates'] print(tasks)
copy

You can also remove an item from the list by specifying its value. Here's how to do that.

123
tasks = ['email Ann', 'call Max', 'meet with classmates'] tasks.remove('call Max') print(tasks)
copy

Now, the list is down to two items instead of three:

  • tasks[0] reads 'email Ann';
  • tasks[1] reads 'meet with classmates'.

Note

With the remove() method, you can only take out one item at a time.

Task

You've got this list:

numbers = [10, 12, 14, 16, 18, 20]

Your goal is to end up with:

numbers = [12, 14, 16]

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!

Imagine you have this list:

12
tasks = ['email Ann', 'call Max', 'meet with classmates'] print(tasks)
copy

You can also remove an item from the list by specifying its value. Here's how to do that.

123
tasks = ['email Ann', 'call Max', 'meet with classmates'] tasks.remove('call Max') print(tasks)
copy

Now, the list is down to two items instead of three:

  • tasks[0] reads 'email Ann';
  • tasks[1] reads 'meet with classmates'.

Note

With the remove() method, you can only take out one item at a time.

Task

You've got this list:

numbers = [10, 12, 14, 16, 18, 20]

Your goal is to end up with:

numbers = [12, 14, 16]

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Section 1. Chapter 10
Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
some-alt