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

Conteúdo do Curso

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.

Tarefa

Suppose you have the following tuple:

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

Tudo estava claro?

Seção 3. Capítulo 4
toggle bottom row
course content

Conteúdo do Curso

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.

Tarefa

Suppose you have the following tuple:

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

Tudo estava claro?

Seção 3. Capítulo 4
toggle bottom row
some-alt