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)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay