Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Delete a Tuple | Tuple
Python Data Structures

Delete a Tuple Delete a Tuple

Keep in mind that a tuple is an immutable data structure, which means you can't make changes to it once it's been created. This includes removing items from the tuple. However, you can delete the entire tuple using the del statement.

Removing Items

Note

There's a workaround if you want to remove items from a tuple. First, you need to convert the tuple into a list since lists are mutable and can be modified. After making the desired changes to the list, you can then convert it back into a tuple.

Let's dive into an example.

Task

Suppose you have the following tuple:

You want to remove the following items:
banana, grape, peach

Everything was clear?

Section 3. Chapter 4
toggle bottom row
course content

Course Content

Python Data Structures

Delete a Tuple Delete a Tuple

Keep in mind that a tuple is an immutable data structure, which means you can't make changes to it once it's been created. This includes removing items from the tuple. However, you can delete the entire tuple using the del statement.

Removing Items

Note

There's a workaround if you want to remove items from a tuple. First, you need to convert the tuple into a list since lists are mutable and can be modified. After making the desired changes to the list, you can then convert it back into a tuple.

Let's dive into an example.

Task

Suppose you have the following tuple:

You want to remove the following items:
banana, grape, peach

Everything was clear?

Section 3. Chapter 4
toggle bottom row
some-alt