DEV Community

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

Posted on

1

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

Explica este código Python

Dificultad: Intermedio

cl = []
print(cl * 2)
Enter fullscreen mode Exit fullscreen mode
  • A. 2
  • B. []
  • C. [] []
  • D. Error

Respuesta:

👉 B. []

Cuando multiplicamos una lista por un número en Python, los items de la lista se repiten por el número de veces que se estableció en la multiplicación.

Si tenemos [1, 2] * 2 tendríamos [1, 2, 1, 2].

Ahora tenemos una multiplicación de una lista vacía por 2, como no hay items que repetir entonces solo regresamos una nueva lista vacía.

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

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay