Merge dictionaries

In Python 3.9+, merging a dictionary is straight-forward. Just use the pipe | symbol.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Our first dictionary
first = {"Temperature": 25}

# Our second dictionary
second = {"Season": "Summer"}

# Combine the two dictionaries into one.
combined = first | second

print(combined)
>{'Temperature': 25, 'Season': 'Summer'}