Created
December 23, 2022 08:31
-
-
Save tinshade/e29000b6778f0471df3313e7a4bd6f66 to your computer and use it in GitHub Desktop.
Little example script for writing dictionary comprehensions.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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