DEV Community

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

Posted on

1

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

Explica este código Python

Dificultad: Fácil

lis = [10, 20, 30, 40]
for m in lis:
    print(m, end=' ')
    if m >= 30:
        break
Enter fullscreen mode Exit fullscreen mode
  • A. 10 20 30
  • B. 10 20 30 40
  • C. 10 20
  • D. 10 20 40

Respuesta:

👉 A. 10 20 30

Recorremos la lista y vamos imprimiendo valor por valor gracias al variable m hasta llegar al valor donde m=30, entonces procedemos a imprimir su valor y luego entramos a la condicional donde terminamos el bucle.

Es importante notar que los valores se imprimen antes que se ejecute la condicional, por este motivo es que 30 también se imprime.

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

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

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

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay