Skip to content

Instantly share code, notes, and snippets.

@tinshade
Created December 23, 2022 08:31
Show Gist options
  • Save tinshade/e29000b6778f0471df3313e7a4bd6f66 to your computer and use it in GitHub Desktop.
Save tinshade/e29000b6778f0471df3313e7a4bd6f66 to your computer and use it in GitHub Desktop.
Little example script for writing dictionary comprehensions.
data= [
{'_id': '1001', 'data': [{'_id':1, 'variation': 1, 'quantity': 25}]},
{'_id': '1000', 'data': [{'_id': 3, 'variation': 1, 'quantity': 0}]}
]
data = {x['_id']:x['data'] for x in data}
print(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment