Skip to content

Instantly share code, notes, and snippets.

@barrachri
Last active October 28, 2019 12:26
Show Gist options
  • Save barrachri/536cacce5eeacd48ceae43594aa847d1 to your computer and use it in GitHub Desktop.
Save barrachri/536cacce5eeacd48ceae43594aa847d1 to your computer and use it in GitHub Desktop.
events = {}
data = [1, 2]
if "id" in events:
events["id"].extend(data)
else:
events["id"] = [*data]
############## 🔥 setdefault ##############
events.setdefault("id", []).extend(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment