Skip to content

Instantly share code, notes, and snippets.

@sebastianschramm
Created August 14, 2022 12:49
Show Gist options
  • Save sebastianschramm/126c30b1b8e1aab700540476f9dc0e72 to your computer and use it in GitHub Desktop.
Save sebastianschramm/126c30b1b8e1aab700540476f9dc0e72 to your computer and use it in GitHub Desktop.
Two ways to combine two dictionaries with unique keys
first_dict = {"a": 1, "b": "foo"}
second_dict = {"c": 1, "d": 5.5, "e": "bar"}
combined_dict_1 = first_dict | second_dict
combined_dict_2 = {**first_dict, **second_dict}
assert combined_dict_1 == combined_dict_2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment