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 AssemblyAI

Automatic Speech Recognition with AssemblyAI

Experience near-human accuracy, low-latency performance, and advanced Speech AI capabilities with AssemblyAI's Speech-to-Text API. Sign up today and get $50 in API credit. No credit card required.

Try the API

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay