Ibuprofeno.py💊| #128: Explica este código 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 …


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

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'}


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


Print Share Comment Cite Upload Translate Updates
APA

Cristian Fernando | Sciencx (2024-06-28T11:00:00+00:00) Ibuprofeno.py💊| #128: Explica este código Python. Retrieved from https://www.scien.cx/2024/06/28/ibuprofeno-py%f0%9f%92%8a-128-explica-este-codigo-python/

MLA
" » Ibuprofeno.py💊| #128: Explica este código Python." Cristian Fernando | Sciencx - Friday June 28, 2024, https://www.scien.cx/2024/06/28/ibuprofeno-py%f0%9f%92%8a-128-explica-este-codigo-python/
HARVARD
Cristian Fernando | Sciencx Friday June 28, 2024 » Ibuprofeno.py💊| #128: Explica este código Python., viewed ,<https://www.scien.cx/2024/06/28/ibuprofeno-py%f0%9f%92%8a-128-explica-este-codigo-python/>
VANCOUVER
Cristian Fernando | Sciencx - » Ibuprofeno.py💊| #128: Explica este código Python. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/06/28/ibuprofeno-py%f0%9f%92%8a-128-explica-este-codigo-python/
CHICAGO
" » Ibuprofeno.py💊| #128: Explica este código Python." Cristian Fernando | Sciencx - Accessed . https://www.scien.cx/2024/06/28/ibuprofeno-py%f0%9f%92%8a-128-explica-este-codigo-python/
IEEE
" » Ibuprofeno.py💊| #128: Explica este código Python." Cristian Fernando | Sciencx [Online]. Available: https://www.scien.cx/2024/06/28/ibuprofeno-py%f0%9f%92%8a-128-explica-este-codigo-python/. [Accessed: ]
rf:citation
» Ibuprofeno.py💊| #128: Explica este código Python | Cristian Fernando | Sciencx | https://www.scien.cx/2024/06/28/ibuprofeno-py%f0%9f%92%8a-128-explica-este-codigo-python/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.