DEV Community

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

Posted on

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)