DEV Community

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

Posted on • Edited on

2

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

Explica este código Python

Dificultad: Fácil

x = {1, 2, 3}
x.add(10)
print(x)
Enter fullscreen mode Exit fullscreen mode
  • A. {10, 1, 2, 3}
  • B. {1, 2, 3}
  • C. {10}
  • D. Ninguno de los anteriores

Respuesta:

👉 A. {10, 1, 2, 3}

Para agregar items a un conjunto se debe usar el método add().
Se verifica que el item a agregar no exista en el conjunto, si existe entonces no lo agrega.

Top comments (0)

Eliminate Context Switching and Maximize Productivity

Pieces.app

Pieces Copilot is your personalized workflow assistant, working alongside your favorite apps. Ask questions about entire repositories, generate contextualized code, save and reuse useful snippets, and streamline your development process.

Learn more