DEV Community

Cristian Fernando
Cristian Fernando

Posted on

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

Explica este código Python

Dificultad: Fácil

my_dict = {"a":1, "b":2, "c":3}
resultado = my_dict.popitem()
print(resultado)
Enter fullscreen mode Exit fullscreen mode
  • A. ("a", 1)
  • B. ("c", 3)
  • C. ("b", 2)
  • D. {"c": 3}

Respuesta:

👉 B. ("c", 3)

Los diccionarios tienen el método popitem() que aparte de eliminar el último par clave valor del diccionario al que se lo apliquemos, también regresa dicho par clave valor en una tupla.

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more