What is the output of the following? d = {‘a’: 1, ‘b’: 2} d2 = {**d, ‘b’: 99, ‘c’: 3} print(d2)

Python Developer Medium

Python Developer — Medium

What is the output of the following? d = {‘a’: 1, ‘b’: 2} d2 = {**d, ‘b’: 99, ‘c’: 3} print(d2)

Key points

  • Dictionary d2 is created by unpacking dictionary d and updating values for specific keys.
  • The key 'b' in dictionary d2 is updated to 99.
  • A new key 'c' with value 3 is added to dictionary d2.

Ready to go further?

Related questions