DEV Community

Cristian Fernando
Cristian Fernando

Posted on

Ibuprofeno.py💊| #142: Explica este código Python

Explica este código Python

Dificultad: Intermedio

lista = [6,7,8,9,10]

res_filter = list(filter(lambda x: x > 8 ,lista))
print(res_filter)
Enter fullscreen mode Exit fullscreen mode
  • A. [9, 10]
  • B. [6, 7, 8, 9, 10]
  • C. [1, 2, 3, 4, 5, 6, 7]
  • D. [8, 9, 10]

Respuesta:

👉 A. [9, 10]

filter() se encarga de hacer un filtrado de un iterable, en nuestro ejemplo aplicamos la condición x > 8 a toda la lista lista, entonces regresamos una nueva lista que solo tenga los items que cumplan con la condición dada.

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more