We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents ab87bc8 + b1abbd6 commit c8413bfCopy full SHA for c8413bf
blog_files/pysheet.md
@@ -1225,6 +1225,22 @@ Using `setdefault` we could make the same code more shortly:
1225
'w': 2,
1226
'y': 1}
1227
```
1228
+### Merge two dictionaries
1229
+
1230
+```python
1231
+# in Python 3.5+:
1232
+>>> x = {'a': 1, 'b': 2}
1233
+>>> y = {'b': 3, 'c': 4}
1234
+>>> z = {**x, **y}
1235
+>>> z
1236
+{'c': 4, 'a': 1, 'b': 3}
1237
1238
+# in Python 2.7
1239
+>>> z = dict(x, **y)
1240
1241
1242
+```
1243
1244
1245
## sets
1246
0 commit comments