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

ibuprofeno.py|-#128:-explica-este-codigo-python

Explica este código Python


Dificultad: Intermedio

x = {"a", "b", "c"}
x.remove("x")
print(x)
  • A. {}
  • B. {"a", "b", "c"}
  • C. KeyError
  • D. SyntaxError

Respuesta:

👉 C. KeyError

Para poder eliminar items de un conjunto usamos el método remove().

Si el item a eliminar no existe en el conjunto entonces regresamos un KeyError.

Por ejemplo, para eliminar el item a tendriamos:

x = {"a", "b", "c"}
x.remove("a")
print(x) # {'b', 'c'}

Total
0
Shares
Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post
top-product-management-reads-in-june

Top product management reads in June

Next Post
what-should-agencies-do-in-a-flat-growth-year?

What Should Agencies Do in a Flat-Growth Year?

Related Posts