DEV Community

Cristian Fernando
Cristian Fernando

Posted on • Edited on

1

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

Explica este código Python

Dificultad: Intermedio

## Reto #67
my_dict = {"a":1, "b":2}
my_dict2 = {"x":-1, "y":-2}
print(my_dict | my_dict2)
Enter fullscreen mode Exit fullscreen mode

👉 A. {'a': 1, 'b': 2}, {'x': -1, 'y': -2}
👉 B. {'a': 1, 'b': 2, 'x': -1, 'y': -2}
👉 C. [{'a': 1, 'b': 2}, {'x': -1, 'y': -2}]
👉 D. ({'a': 1, 'b': 2}, {'x': -1, 'y': -2})


Respuesta en el primer comentario.

Top comments (1)

Collapse
 
duxtech profile image
Cristian Fernando

Respuesta:
👉 B. {'a': 1, 'b': 2, 'x': -1, 'y': -2}

A partir de Python 3.9 podemos usar el operador | para poder combinar diccionarios sin la necesidad de crear uno nuevo. Es un manera más moderna de llegar al mismo resultado.

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more