What will `{**{‘a’:1}, **{‘a’:2}}` evaluate to?

Python Professional Hard

Python Professional — Hard

What will `{**{‘a’:1}, **{‘a’:2}}` evaluate to?

Key points

  • The double asterisks unpack the dictionaries into a new dictionary.
  • When there are duplicate keys, the last one takes precedence.
  • This is an example of dictionary unpacking in Python.

Ready to go further?

Related questions