Introducci贸n

1

El Zen de Python

Conjuntos

2

Sets

3

Modificando conjuntos

4

Operaciones con conjuntos

5

Playgrounds: Elimina elementos duplicados usando conjuntos

Comprehensions

6

List Comprehension

7

Dictionary Comprehension

8

Dictionary Comprehension: condition

9

Playgrounds: Crea una lista usando List Comprehension

10

Lists vs. Tuples vs. Sets

Funciones

11

Funciones

12

Funciones: return

13

Par谩metros por defecto y m煤ltiples returns

14

El scope

15

Refactor game

16

Playgrounds: Tienda de Tecnolog铆a

17

Funciones an贸nimas: lambda

18

Higher order function: una funci贸n dentro de otra funci贸n

19

Map

20

Map con diccionarios

21

Reto: map con inmutabilidad

22

Playgrounds: Multiplica todos los elementos por dos

23

Filter

24

Playgrounds: Retorna solo palabras de 4 letras y m谩s

25

Reduce

M贸dulos

26

M贸dulos

27

Mis propios m贸dulos

28

M贸dulos como scripts: __name__ y __main__

29

Paquetes

30

Playgrounds: Calcular la suma de todas las compras

Manipulaci贸n de archivos y errores

31

Iterables

32

Errores en Python

33

Manejo de excepciones

34

Playgrounds: Captura la excepci贸n: ZeroDivisionError

35

Leer un archivo de texto

36

Escribir en un archivo

37

Leer un CSV

38

Playgrounds: Lee un CSV para calcular el total de gastos

Gr谩ficas en Python

39

Creando una gr谩fica

40

Reto: graficando la poblaci贸n de un pa铆s

41

Reto: graficando la poblaci贸n mundial

Pr贸ximos pasos

42

隆Conoce otros proyectos de este curso!

43

Reconoce tu proceso y certif铆cate

44

Toma el Curso de PIP y Entornos Virtuales con Python

No tienes acceso a esta clase

隆Contin煤a aprendiendo! 脷nete y comienza a potenciar tu carrera

Playgrounds: Crea una lista usando List Comprehension

9/44

Aportes 205

Preguntas 4

Ordenar por:

驴Quieres ver m谩s aportes, preguntas y respuestas de la comunidad?

o inicia sesi贸n.

Esta es la soluci贸n que realice para este desaf铆o:

numbers = [35, 16, 10, 34, 37, 25]

even_numbers = []
for number in numbers:
  if number % 2 == 0:
    even_numbers.append(number)
print('v1 =>', even_numbers)

# Ahora usando List Comprehension 馃憞
even_numbers_v2 = [number for number in numbers if number % 2 == 0]

print('v2 =>', even_numbers_v2)

Es un gran logro para mi que me resulte a al primera, esto porque he tenido muchas dificultades de tiempo y no he conseguido tomar clases seguido, por tal raz贸n, recordar la sintaxis y dem谩s me es muy significativo a nivel personal.

Cada vez entendiendo mas

even_numbers_v2 = [number for number in numbers if number % 2 == 0]

Esta es mi soluci贸n, abierto a sugerencias.
numbers = [35, 16, 10, 34, 37, 25]

even_numbers = []
for number in numbers:
if number % 2 == 0:
even_numbers.append(number)
print('v1 => ', even_numbers)

Ahora usando List Comprehension 馃憞

even_numbers_v2 = [i*1 for i in numbers if i%2==0 ]

print('v2 => ', even_numbers_v2)

Buenas, les dejo mi soluci贸n, espero sea se ayuda, saludos: numbers = \[35, 16, 10, 34, 37, 25] even\_numbers = \[]for number in numbers:聽 if number % 2 == 0:聽 聽 even\_numbers.append(number)print('v1 =>', even\_numbers) \# Ahora usando List Comprehension 馃憞even\_numbers\_v2 = \[number for number in numbers if number % 2 == 0] print('v2 =>', even\_numbers\_v2)
Despu茅s de repasar por mas de 1 hora los ejemplos de las clases anteriores me di cuenta que estaba poniendo mal el orden de las variables pero por fin lo logre ![](https://static.platzi.com/media/user_upload/image-3e68ccfa-79af-4576-bbcb-46be6abf2d30.jpg)

Soluci贸n:

even_numbers_v2 = [ number for number in numbers if number % 2 == 0]

Aca tengo mi ejemplo donde tambien extraemos los numeros impares!

numbers = [35, 16, 10, 34, 37, 25]

even_numbers = []
for number in numbers:
  if number % 2 == 0:
    even_numbers.append(number)
print('v1 =>', even_numbers)

# Ahora usando List Comprehension 馃憞
even_numbers_v2 = [numeros for numeros in numbers if numeros % 2 == 0]

even_numbers_v3 = [numeros for numeros in numbers if numeros % 2 != 0]

print('v2 =>', even_numbers_v2)
print('v3 =>', even_numbers_v3)
numbers = \[35, 16, 10, 34, 37, 25] even\_numbers = \[]for number in numbers:聽 if number % 2 == 0:聽 聽 even\_numbers.append(number)print('v1 =>', even\_numbers) \# Ahora usando List Comprehension 馃憞even\_numbers\_v2 = \[ number for number in numbers if number % 2 == 0]聽print('v2 =>', even\_numbers\_v2)
```python numbers = [35, 16, 10, 34, 37, 25] even_numbers = [] for number in numbers: if number % 2 == 0: even_numbers.append(number) print('v1 =>', even_numbers) # Ahora usando List Comprehension 馃憞 even_numbers_v2 = [number for number in numbers if number % 2 == 0] print('v2 =>', even_numbers_v2) ```

Mi soluci贸n

even_numbers_v2 = [number for number in numbers if number % 2 == 0]

print('v2 =>', even_numbers_v2)

Me gusto el ejercicio y como este se llega a implementar en nusetro codigo. Me alegra seguir aprendiendo en python. Sere uno de los mejores.

```python numbers = [35, 16, 10, 34, 37, 25] even_numbers = [] for number in numbers: if number % 2 == 0: even_numbers.append(number) print('v1 =>', even_numbers) even_numbers_v2 = [i for i in numbers if i % 2 == 0] print('v2 =>', even_numbers_v2) ```Estoy repitiendo este curso por q me hab铆an quedado muchas dudas, ahora lo puedo entender mucho mejor.

Increible鈥
por un momento pense que no sabia, pero ahora ya se.

```python numbers = [35, 16, 10, 34, 37, 25] even_numbers = [] for number in numbers: if number % 2 == 0: even_numbers.append(number) print('v1 =>', even_numbers) # Ahora usando List Comprehension 馃憞 even_numbers_v2 = [number for number in numbers if number % 2 == 0] print('v2 =>', even_numbers_v2) ```
Os dejo una posible soluci贸n: even\_numbers\_v2 = \[n for n in numbers if n % 2 == 0] print('v2 =>', even\_numbers\_v2)
`#Crea una lista usando List Comprehension` `numbers = [35, 16, 10, 34, 37, 25]` `even_numbers = []` `for number in numbers:聽 ` `if number % 2 == 0:聽 聽 ` `even_numbers.append(number)` `print('v1 =>', even_numbers)` `# Soluci贸n 馃憞` `even_numbers_v2 = [number for number in numbers if number % 2 == 0]` `print('v2 =>', even_numbers_v2)`
numbers = [35, 16, 10, 34, 37, 25]

even_numbers = []
for number in numbers:
  if number % 2 == 0:
    even_numbers.append(number)
print('v1 =>', even_numbers)

# Ahora usando List Comprehension 馃憞
even_numbers_v2 = [number for number in numbers if number % 2 == 0]

print('v2 =>', even_numbers_v2)
![](https://static.platzi.com/media/user_upload/image-9963cbac-83c2-4e56-a42a-d4cb5601ed25.jpg)
even\_numbers\_v2 = \[number for number in numbers if number % 2 == 0]

reto cumplido

numbers = [35, 16, 10, 34, 37, 25]

even_numbers = []
for number in numbers:
  if number % 2 == 0:
    even_numbers.append(number)
print('v1 =>', even_numbers)

# Ahora usando List Comprehension 馃憞
even_numbers_v2 = [number for number in numbers if number % 2 == 0]

print('v2 =>', even_numbers_v2)```
```js numbers = [35, 16, 10, 34, 37, 25] even_numbers = [] for number in numbers: if number % 2 == 0: even_numbers.append(number) print('v1 =>', even_numbers) # Ahora usando List Comprehension 馃憞 even_numbers_v2 = [item for item in numbers if item %2==0] print('v2 =>', even_numbers_v2) ```numbers = \[35, 16, 10, 34, 37, 25] even\_numbers = \[]for number in numbers:聽 if number % 2 == 0:聽 聽 even\_numbers.append(number)print('v1 =>', even\_numbers) \# Ahora usando List Comprehension 馃憞even\_numbers\_v2 = \[item for item in numbers if item %2==0] print('v2 =>', even\_numbers\_v2)
tal vez esto ayude. ![](https://static.platzi.com/media/user_upload/image-2b0e6037-7c56-424a-b76e-f1d7d309cba5.jpg)![](https://static.platzi.com/media/user_upload/image-8b784ab6-8ef0-4859-892d-064878bb3a65.jpg)
![](https://static.platzi.com/media/user_upload/image-4b2ecee9-c1e0-481b-b1d0-3324d123857a.jpg)
numbers = \[35, 16, 10, 34, 37, 25] even\_numbers\_v2 = \[serie for serie in numbers if serie % 2 == 0] print('v2 =>', even\_numbers\_v2) me funciono al pelo :-)
even_numbers_v2 = [number for number in numbers if number % 2 == 0]

Mi aporte.! numbers = \[35, 16, 10, 34, 37, 25] even\_numbers = \[] for number in numbers:聽 if number % 2 == 0:聽 聽 even\_numbers.append(number) print('v1 =>', even\_numbers) \# Ahora usando List Comprehension 馃憞even\_numbers\_v2 = \[i for i in numbers if i % 2 == 0] print('v2 =>', even\_numbers\_v2)

numbers = [35, 16, 10, 34, 37, 25]

even_numbers = []
for number in numbers:
if number % 2 == 0:
even_numbers.append(number)
print(鈥榲1 =>鈥, even_numbers)

Ahora usando List Comprehension 馃憞

even_numbers_v2 = [number for number in numbers if number % 2 == 0]

print(鈥榲2 =>鈥, even_numbers_v2)

As铆 qued贸 mi c贸digo:


Les dejo mi aporte

numbers = [35, 16, 10, 34, 37, 25]
even_numbers = []
for number in numbers:
if number % 2 == 0:
even_numbers.append(number)
print(鈥榲1 =>鈥, even_numbers)

respuesta deirecta y sencilla

even_numbers_v2 = [number for number in numbers if number % 2 == 0]
print(鈥榲2 =>鈥, even_numbers_v2)

numbers = [35, 16, 10, 34, 37, 25]

even_numbers = []
for number in numbers:
  if number % 2 == 0:
    even_numbers.append(number)
print('v1 =>', even_numbers) 

# Ahora usando List Comprehension 馃憞
even_numbers_v2 = [number for number in numbers if number % 2 == 0]
 
print('v2 =>', even_numbers_v2) 

Resultado
v1 => [16, 10, 34]
v2 => [16, 10, 34]

Hola a todos! Esta es la linea que agregue para la soluci贸n:

even_numbers_v2 = [n for n in numbers if n % 2 == 0]

Mi soluci贸n, me sali贸 a la primera, creo que por ahora he aprendido de una manera sobresaliente y siento que voy por buen camino.

numbers = [35, 16, 10, 34, 37, 25]

even_numbers = []
for number in numbers:
if number % 2 == 0:
even_numbers.append(number)
print(鈥榲1 =>鈥, even_numbers)

Ahora usando List Comprehension 馃憞

even_numbers_v2 = [number for number in numbers if number % 2 == 0]

print(鈥榲2 =>鈥, even_numbers_v2)

numbers = [35, 16, 10, 34, 37, 25]

even_numbers = []
for number in numbers:
if number % 2 == 0:
even_numbers.append(number)
print(鈥榲1 =>鈥, even_numbers)

Ahora usando List Comprehension 馃憞

even_numbers_v2 = [numero for numero in numbers if numero % 2 ==0 ]

print(鈥榲2 =>鈥, even_numbers_v2)

numbers = [35, 16, 10, 34, 37, 25]

even_numbers = []
for number in numbers:
  if number % 2 == 0:
    even_numbers.append(number)
print('v1 =>', even_numbers)

# Ahora usando List Comprehension 馃憞
even_numbers_v2 = [number for number in numbers if number%2==0]

print('v2 =>', even_numbers_v2)
numbers = [35, 16, 10, 34, 37, 25]

even_numbers = []
for number in numbers:
  if number % 2 == 0:
    even_numbers.append(number)
print('v1 =>', even_numbers)

# Ahora usando List Comprehension 馃憞
even_numbers_v2 = [number for number in numbers if number % 2 == 0]

print('v2 =>', even_numbers_v2)

hola es dif铆cil no me da a la primera

numbers = [35, 16, 10, 34, 37, 25]

even_numbers = []
for number in numbers:
  if number % 2 == 0:
    even_numbers.append(number)
print('v1 =>', even_numbers)

# Ahora usando List Comprehension 馃憞
even_numbers_v2 = list({number: number for number in numbers if(number % 2 == 0)})

print('v2 =>', even_numbers_v2)

mi aporte

Me siento re feliz cuando acierto los playgrounds 馃榿, por cierto, las list comprehension son lo mismo de un ciclo for pero en una sola l铆nea. Aqu铆 mi soluci贸n


.
.
.
.
.
.
.
.
.

numbers = [35, 16, 10, 34, 37, 25]

even_numbers = []
for number in numbers:
  if number % 2 == 0:
    even_numbers.append(number)
print('v1 =>', even_numbers)

# Ahora usando List Comprehension 馃憞
even_numbers_v2 = [i for i in numbers if i % 2 == 0]

print('v2 =>', even_numbers_v2)

Esta fue mi solucion:

numbers = [35, 16, 10, 34, 37, 25]

even_numbers = []
for number in numbers:
  if number % 2 == 0:
    even_numbers.append(number)
print('v1 =>', even_numbers)

# Ahora usando List Comprehension 馃憞

even_numbers_v2 = [x for x in numbers if x % 2 == 0]
print('v2 =>', even_numbers_v2)

)

even_numbers_v2 = [ number for number in numbers if number % 2 == 0 ]
v1 => [16, 10, 34]

v2 => [16, 10, 34]

Listo !

TRADICIONAL

numbers = [35, 16, 10, 34, 37, 25]
even_numbers_v1 = []
for number in numbers:
if number % 2 == 0:
even_numbers_v1.append(number)
print(鈥榁ERSI脫N 1 =>鈥,even_numbers_v1)

COMPREHENSION

even_numbers_v2 = [number for number in numbers if number % 2 == 0]
print(鈥榁ERSI脫N 2 =>鈥,even_numbers_v2)

numbers = [35, 16, 10, 34, 37, 25]

even_numbers = []
for number in numbers:
  if number % 2 == 0:
    even_numbers.append(number)
print('v1 =>', even_numbers)

# Ahora usando List Comprehension 馃憞
even_numbers_v2 = [number for number in numbers if number%2==0]

print('v2 =>', even_numbers_v2)


.
.
.
.
.

numbers = [35, 16, 10, 34, 37, 25]

even_numbers = []
for number in numbers:
  if number % 2 == 0:
    even_numbers.append(number)
print('v1 =>', even_numbers)

even_numbers_v2 = []
even_numbers_v2 = [number for number in numbers if number % 2 == 0]

print('v2 =>', even_numbers_v2)


.
.
.

<numbers = [35, 16, 10, 34, 37, 25]

even_numbers = []
for number in numbers:
  if number % 2 == 0:
    even_numbers.append(number)
print('v1 =>', even_numbers)

# Ahora usando List Comprehension 馃憞
even_numbers_v2 = [ i for i in numbers if i % 2 == 0]

print('v2 =>', even_numbers_v2)> 

numbers = [35, 16, 10, 34, 37, 25]

even_numbers = []
for number in numbers:
if number % 2 == 0:
even_numbers.append(number)
print(鈥榲1 =>鈥, even_numbers)

Ahora usando List Comprehension 馃憞

even_numbers_v2 = [number for number in numbers if number % 2 == 0]

print(鈥榲2 =>鈥, even_numbers_v2)

Ahora usando List Comprehension 馃憞

even_numbers_v2 = [number for number in numbers if number % 2 == 0]

print(鈥榲2 =>鈥, even_numbers_v2)

<numbers = [35, 16, 10, 34, 37, 25]

even_numbers = []
for number in numbers:
  if number % 2 == 0:
    even_numbers.append(number)
print('v1 =>', even_numbers)

# Ahora usando List Comprehension 馃憞
even_numbers_v2 = [i for i in numbers if i %2==0]

print('v2 =>', even_numbers_v2)> 

Comprender los for ha sido mi n茅mesis en diversos lenguajes para m铆, digamos que mi l贸gica natural de c贸mo se deber铆an hacer las cosas es distinta a la l贸gica de la m谩quina, por lo que he tenido que hacer un esfuerzo gigante de desaprender y adoptar la abstracci贸n del lenguaje de programaci贸n. por lo tanto, ac谩 publico esta pseudo explicaci贸n de c贸mo fue que pude entender estas comprehensions y desarrollar el reto con mayor facilidad. Espero sea de ayuda, no estar errado y sea aporte con valor, en caso de estar errado agradezco el feedback para darlo de baja y no confundir m谩s estudiantes.

numbers = [35, 16, 10, 34, 37, 25]

Explicaci贸n:

Se crea una lista vac铆a llamada even_numbers, la siguente l铆nea crea un bucle donde por cada number dentro de numbers, (siguiente l铆nea) si number mod 2 da 0 como resultado (o sea, es par), (siguiente l铆nea) sea agreguado number a la lista even numbers con la funci贸n .append()

even_numbers = []
for number in numbers:
  if number % 2 == 0:
    even_numbers.append(number)
print('v1 =>', even_numbers)

Ahora usando List Comprehension 馃憞

Explicaci贸n:

Se crea la lista even_numbers_v2, se guardar谩 en la lista el number que, por cada number dentro de numbers, si el number es par.

Eplicaci贸n en lenguaje natural:

Se crea la lista even_numbers_v2, el recorrido de m谩quina inicia desde el for, por cada number dentro de la lista numbers, si number mod 2 da 0 (o sea, si es par), guarde los que cumplan la condici贸n en number (el que est谩 antes del for), y ese number ser谩 el que ir谩 dentro de la lista even_numbers_v2
#Otra forma en la que se podr铆a interpretar el recorrido de la m谩quina, es que inicia desde number, pero este est谩 vac铆o, por lo que no guarda nada y contin煤a con el bucle, al filtrar el primer resultado, lo guarda en number y este en la lista y repite el bucle

even_numbers_v2 = [number for number in numbers if number %2 ==0]

print('v2 =>', even_numbers_v2)

Resultado:

<code> 
even_numbers_v2 = [n for n in numbers if n % 2 == 0]
numbers = [35, 16, 10, 34, 37, 25]

even_numbers = []
for number in numbers:
  if number % 2 == 0:
    even_numbers.append(number)
print('v1 =>', even_numbers)

# Ahora usando List Comprehension 馃憞
even_numbers_v2 = [number for number in numbers if number % 2 == 0]


print('v2 =>', even_numbers_v2)

Soluci贸n del reto:

numbers = [35, 16, 10, 34, 37, 25]

even_numbers = []
for number in numbers:
  if number % 2 == 0:
    even_numbers.append(number)
print('v1 =>', even_numbers)

# Ahora usando List Comprehension 馃憞
even_numbers_v2 = [number for number in numbers if number % 2 == 0]

print('v2 =>', even_numbers_v2)

even_numbers_v2 = [number for number in numbers if number % 2 == 0]

print(鈥榲2 =>鈥, even_numbers_v2)

Este es mi aporte

numbers = [35, 16, 10, 34, 37, 25]

even_numbers = []
for number in numbers:
if number % 2 == 0:
even_numbers.append(number)
print(鈥榲1 =>鈥, even_numbers)

Ahora usando List Comprehension 馃憞

even_numbers_v2 = [number for number in numbers if number %2 ==0]
print( 鈥榲2 =>鈥, even_numbers_v2)

Mi soluci贸n en una solo l铆nea:

print(鈥榲2 =>鈥, list(number for number in numbers if number % 2 == 0))

me demore pero lo logre


even_numbers_v2 = [i for i in numbers if i % 2 ==0]
<code> even_numbers_v2 = [number for number in(numbers) if number % 2 == 0 ]

.
.
.
.
.
.
.
.
.
.

numbers = [35, 16, 10, 34, 37, 25]

even_numbers = []
for number in numbers:
  if number % 2 == 0:
    even_numbers.append(number)
print('v1 =>', even_numbers)

# Ahora usando List Comprehension 馃憞
even_numbers_v2 = []
even_numbers_v2 = [num for num in numbers if num % 2 == 0]
print('v2 =>', even_numbers_v2)
  • el number de que es el elemento que itera sale del for iterando en la list numbers pero solo para numbers pares.

numbers = [35, 16, 10, 34, 37, 25]

even_numbers = []
for number in numbers:
if number % 2 == 0:
even_numbers.append(number)
print(鈥榲1 =>鈥, even_numbers)

Ahora usando List Comprehension 馃憞

even_numbers_v2 = [numero for numero in numbers if numero % 2 == 0]

print(鈥榲2 =>鈥, even_numbers_v2)

Me gusta mas poner 鈥榠鈥 en el for. Estudi茅 mate y me es super natural pensar en el 鈥榠鈥 :v.

Reto cumplido

``
numbers = [35, 16, 10, 34, 37, 25]

even_numbers = []
for number in numbers:
  if number % 2 == 0:
    even_numbers.append(number)
print('v1 =>', even_numbers)

# Ahora usando List Comprehension 馃憞

even_numbers_v2 = []
even_numbers_v2 = [valor for valor in numbers if (valor % 2) == 0]

print('v2 =>', even_numbers_v2)
```

La soluci贸n es la siguiente:

numbers = [35, 16, 10, 34, 37, 25]

even_numbers = []
for number in numbers:
  if number % 2 == 0:
    even_numbers.append(number)
print('v1 =>', even_numbers)

# Ahora usando List Comprehension 馃憞
even_numbers_v2 = []

even_numbers_v2 = [i for i in numbers if i % 2 == 0]

print('v2 =>', even_numbers_v2)
even_numbers_v2 = [number for number in numbers if not number % 2]

numbers = [35, 16, 10, 34, 37, 25]

even_numbers = []
for number in numbers:
if number % 2 == 0:
even_numbers.append(number)
print(鈥榲1 =>鈥, even_numbers)

Ahora usando List Comprehension 馃憞

even_numbers_v2 = []

print(鈥榲2 =>鈥, even_numbers_v2)

ac谩 mi respuesta

numbers = [35, 16, 10, 34, 37, 25]

even_numbers = []
for number in numbers:
if number % 2 == 0:
even_numbers.append(number)
print(鈥榲1 =>鈥, even_numbers)

Ahora usando List Comprehension 馃憞

even_numbers_v2 = []
even_numbers_v2 = [i for i in numbers if i % 2 == 0]
print(鈥榲2 =>鈥, even_numbers_v2)

numbers = [35, 16, 10, 34, 37, 25]

even_numbers = []
for number in numbers:
  if number % 2 == 0:
    even_numbers.append(number)
print('v1 =>', even_numbers)

# Ahora usando List Comprehension 馃憞
even_numbers_v2 = [number for number in numbers if number % 2 == 0]

print('v2 =>', even_numbers_v2)
numbers = [35, 16, 10, 34, 37, 25]

even_numbers = []
for number in numbers:
  if number % 2 == 0:
    even_numbers.append(number)
print('v1 =>', even_numbers)

# Ahora usando List Comprehension 馃憞
even_numbers_v2 = [number for number in numbers if number % 2 == 0 ]

print('v2 =>', even_numbers_v2)

Bastante sencillo

even_numbers_v2 = [number for number in numbers if number % 2 == 0]

Mientras mas simple el codigo, mejor

even_numbers_v2 = [number for number in numbers if number % 2 == 0]

numbers = [35, 16, 10, 34, 37, 25]

even_numbers = []
for number in numbers:
if number % 2 == 0:
even_numbers.append(number)
print(鈥榲1 =>鈥, even_numbers)

Soy Marco 鈽 y esta es mi solucion 馃憞

Ahora usando List Comprehension 馃憞

even_numbers_v2 = [number for number in numbers if number % 2 == 0]

print(鈥榲2 =>鈥, even_numbers_v2)

numbers = [35, 16, 10, 34, 37, 25]

even_numbers = []
for number in numbers:
if number % 2 == 0:
even_numbers.append(number)
print(鈥榲1 =>鈥, even_numbers)

even_numbers_v2 = [number for number in numbers if number % 2 == 0]

print(鈥榲2 =>鈥, even_numbers_v2)

![](

El test pasa si envio la lista generada sin usar list comprehension 馃槙

Mi SOLUCION

numbers = [35, 16, 10, 34, 37, 25]

even_numbers = []
for number in numbers:
  if number % 2 == 0:
    even_numbers.append(number)
print('v1 =>', even_numbers)

# Ahora usando List Comprehension 馃憞
even_numbers_v2 = [number for number in numbers if number % 2 == 0]

print('v2 =>', even_numbers_v2)

As铆 llegu茅 al resultado:

numbers = [35, 16, 10, 34, 37, 25]

even_numbers = []
for number in numbers:
if number % 2 == 0:
even_numbers.append(number)
print(鈥榲1 =>鈥, even_numbers)

Ahora usando List Comprehension 馃憞

even_numbers_v2 = [evens for evens in numbers if evens % 2 == 0]

print(鈥榲2 =>鈥, even_numbers_v2)

Mi solucion:

numbers = [35, 16, 10, 34, 37, 25]

even_numbers = []
for number in numbers:
  if number % 2 == 0:
    even_numbers.append(number)
print('v1 =>', even_numbers)

# Ahora usando List Comprehension 馃憞
even_numbers_v2 = [number for number in numbers if number % 2 ==0]

print('v2 =>', even_numbers_v2)```
numbers = [35, 16, 10, 34, 37, 25]

even_numbers = []
for number in numbers:
  if number % 2 == 0:
    even_numbers.append(number)
print('v1 =>', even_numbers)

# Ahora usando List Comprehension 馃憞
even_numbers_v2 = [number for number in numbers if number % 2 == 0]

print('v2 =>', even_numbers_v2)

Mi soluci贸n:

even_numbers_v2 = [number for number in numbers if number % 2 == 0]

numbers = [35, 16, 10, 34, 37, 25]

even_numbers = []
for number in numbers:
if number % 2 == 0:
even_numbers.append(number)
print(鈥榲1 =>鈥, even_numbers)

Ahora usando List Comprehension 馃憞

even_numbers_v2 = [number for number in numbers if number % 2 == 0 ]

print(鈥榲2 =>鈥, even_numbers_v2)

numbers = [35, 16, 10, 34, 37, 25]

even_numbers = []
for number in numbers:
  if number % 2 == 0:
    even_numbers.append(number)
print('v1 =>', even_numbers)

# Ahora usando List Comprehension 馃憞
even_numbers_v2 = [number for number in numbers if number % 2 == 0 ]

print('v2 =>', even_numbers_v2)

numbers = [35, 16, 10, 34, 37, 25]

even_numbers = []
for number in numbers:
if number % 2 == 0:
even_numbers.append(number)
print(鈥榲1 =>鈥, even_numbers)

Ahora usando List Comprehension 馃憞

even_numbers_v2 = [number for number in numbers if number % 2 == 0]

print(鈥榲2 =>鈥, even_numbers_v2)

numbers = [35, 16, 10, 34, 37, 25]

even_numbers = []
for number in numbers:
  if number % 2 == 0:
    even_numbers.append(number)
print('v1 =>', even_numbers)

# Ahora usando List Comprehension 馃憞
even_numbers_v2 = [number for number in numbers if number % 2 == 0]

print('v2 =>', even_numbers_v2)

Mi soluci贸n fuee sta:

numbers = [35, 16, 10, 34, 37, 25]

even_numbers = []
for number in numbers:
  if number % 2 == 0:
    even_numbers.append(number)
print('v1 =>', even_numbers)

even_numbers_v2 = [number for number in numbers if number % 2 == 0]

print('v2 =>', even_numbers_v2)

estuve 20 minutos viendo porque me daba error, y era porque tenia armado en diccionario y no en listaa

undefined