DEV Community

Cover image for Ibuprofeno.py💊| #178: Explica este código Python
Cristian Fernando
Cristian Fernando

Posted on

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

Explica este código Python

Dificultad: Fácil

a = [1, 2, 3, 4, 5]
print(a[:4].pop())
Enter fullscreen mode Exit fullscreen mode
  • A. [1, 2, 3, 4]
  • B. 4
  • C. [1, 2, 3, 5]
  • D. 5

Respuesta:

👉 B. 4

El ejemplo tiene un sclicing de listas seguido del método pop. Luego de slicing tendremos [1, 2, 3, 4] y el método pop no se hace mas que eliminar el último item de la lista y mostrarlo por consola.

Por ello el resultado final es 4.

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