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)

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

👥 Ideal for solo developers, teams, and cross-company projects

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