Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lista Anidada | Lista
Estructuras de Datos en Python
course content

Contenido del Curso

Estructuras de Datos en Python

Estructuras de Datos en Python

1. Lista
2. Diccionario
3. Tupla
4. Conjunto
5. For deleting

bookLista Anidada

Los elementos dentro de una lista Python también pueden ser listas, dando lugar a listas anidadas, a veces denominadas "listas dentro de listas". Aquí tienes un ejemplo de lista anidada:

12
numbers = [1, [1, 2, 3], 2, [3, 4, 5, [7, 9]]] print(numbers)
copy

Using Variables for Nested Lists

This example illustrates a nested list in which the second and fourth elements are also lists, and the fourth element even contains another nested list within it.

You can also create nested lists by concatenating lists held in variables. This can be useful to make your code more readable. For instance:

1234567
europe_cities = ["Paris", "Berlin", "Rome"] asia_cities = ["Tokyo", "Seoul", "Bangkok"] america_cities = ["New York", "Los Angeles", "Chicago"] world_cities = [europe_cities, asia_cities, america_cities] print(world_cities)
copy

Here, we first define three independent lists for cities in Europe, Asia, and the Americas. We then combine the lists into one, world_cities, which becomes a nested list.

The example shows that a nested list is a good way to organize related data, such as cities from different continents, in a natural, intuitive, and organized manner.

Tarea

Construct a list called list_2 containing these elements:

[1, [2, 3], 4, [5, 6], 7]

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 1. Capítulo 2
toggle bottom row

bookLista Anidada

Los elementos dentro de una lista Python también pueden ser listas, dando lugar a listas anidadas, a veces denominadas "listas dentro de listas". Aquí tienes un ejemplo de lista anidada:

12
numbers = [1, [1, 2, 3], 2, [3, 4, 5, [7, 9]]] print(numbers)
copy

Using Variables for Nested Lists

This example illustrates a nested list in which the second and fourth elements are also lists, and the fourth element even contains another nested list within it.

You can also create nested lists by concatenating lists held in variables. This can be useful to make your code more readable. For instance:

1234567
europe_cities = ["Paris", "Berlin", "Rome"] asia_cities = ["Tokyo", "Seoul", "Bangkok"] america_cities = ["New York", "Los Angeles", "Chicago"] world_cities = [europe_cities, asia_cities, america_cities] print(world_cities)
copy

Here, we first define three independent lists for cities in Europe, Asia, and the Americas. We then combine the lists into one, world_cities, which becomes a nested list.

The example shows that a nested list is a good way to organize related data, such as cities from different continents, in a natural, intuitive, and organized manner.

Tarea

Construct a list called list_2 containing these elements:

[1, [2, 3], 4, [5, 6], 7]

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 1. Capítulo 2
toggle bottom row

bookLista Anidada

Los elementos dentro de una lista Python también pueden ser listas, dando lugar a listas anidadas, a veces denominadas "listas dentro de listas". Aquí tienes un ejemplo de lista anidada:

12
numbers = [1, [1, 2, 3], 2, [3, 4, 5, [7, 9]]] print(numbers)
copy

Using Variables for Nested Lists

This example illustrates a nested list in which the second and fourth elements are also lists, and the fourth element even contains another nested list within it.

You can also create nested lists by concatenating lists held in variables. This can be useful to make your code more readable. For instance:

1234567
europe_cities = ["Paris", "Berlin", "Rome"] asia_cities = ["Tokyo", "Seoul", "Bangkok"] america_cities = ["New York", "Los Angeles", "Chicago"] world_cities = [europe_cities, asia_cities, america_cities] print(world_cities)
copy

Here, we first define three independent lists for cities in Europe, Asia, and the Americas. We then combine the lists into one, world_cities, which becomes a nested list.

The example shows that a nested list is a good way to organize related data, such as cities from different continents, in a natural, intuitive, and organized manner.

Tarea

Construct a list called list_2 containing these elements:

[1, [2, 3], 4, [5, 6], 7]

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Los elementos dentro de una lista Python también pueden ser listas, dando lugar a listas anidadas, a veces denominadas "listas dentro de listas". Aquí tienes un ejemplo de lista anidada:

12
numbers = [1, [1, 2, 3], 2, [3, 4, 5, [7, 9]]] print(numbers)
copy

Using Variables for Nested Lists

This example illustrates a nested list in which the second and fourth elements are also lists, and the fourth element even contains another nested list within it.

You can also create nested lists by concatenating lists held in variables. This can be useful to make your code more readable. For instance:

1234567
europe_cities = ["Paris", "Berlin", "Rome"] asia_cities = ["Tokyo", "Seoul", "Bangkok"] america_cities = ["New York", "Los Angeles", "Chicago"] world_cities = [europe_cities, asia_cities, america_cities] print(world_cities)
copy

Here, we first define three independent lists for cities in Europe, Asia, and the Americas. We then combine the lists into one, world_cities, which becomes a nested list.

The example shows that a nested list is a good way to organize related data, such as cities from different continents, in a natural, intuitive, and organized manner.

Tarea

Construct a list called list_2 containing these elements:

[1, [2, 3], 4, [5, 6], 7]

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
Sección 1. Capítulo 2
Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
some-alt