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)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more