DEV Community

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

Posted on

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

Explica este código Python

Dificultad: Intermedio

print([]*3)
Enter fullscreen mode Exit fullscreen mode
  • A. [], [], []
  • B. [ [], [], [] ]
  • C. []
  • D. Value Error

Respuesta:

👉 C. []

Cuando usamos el operador de producto con listas el interprete de Python intentara multiplicar n veces los elementos de dicha lista, por ejemplo:

print([1,2]*2) # [1, 2, 1, 2]
Enter fullscreen mode Exit fullscreen mode

Repetimos todos los items de la lista en este caso 2 veces.

Ahora en nuestro ejemplo tenemos una lista vacía que se repite 3 veces, entonces tenemos la misma lista vacía.


Top comments (0)

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →