DEV Community

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

Posted on

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

Explica este código Python

Dificultad: Fácil

## Reto #64
my_dict = {"name": "John", "age": 30, "city": "New York"}
del my_dict["age"]
print(my_dict)
Enter fullscreen mode Exit fullscreen mode

👉 A. {'name': 'John', 'city': 'New York'}
👉 B. {"name": "John", "age": 30, "city": "New York"}
👉 C. SyntaxError
👉 D. TypeError


Respuesta en el primer comentario.

Top comments (1)

Collapse
 
duxtech profile image
Cristian Fernando

Respuesta:
👉 A. {'name': 'John', 'city': 'New York'}

Una manera de poder eliminar pares clave-valor de un diccionario es usando el operador del. Su sintaxis es muy sencilla de usar e intuitiva de entender.