Ibuprofeno.pyπŸ’Š| #127: Explica este cΓ³digo Python



This content originally appeared on DEV Community and was authored by Cristian Fernando

Explica este cΓ³digo Python

Dificultad: FΓ‘cil

x = {1, 2, 3}
x.add(10)
print(x)
  • 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.


This content originally appeared on DEV Community and was authored by Cristian Fernando