Closed bbelderbos closed 8 months ago
Using a dict comprehension (love Python!), e.g.
>>> daily_values = { ... "Added sugars": {"value": 50, "unit": "g"}, ... "Biotin": {"value": 30, "unit": "mcg"}, ... } >>> daily_values = {key: {"value": 0, "unit": value["unit"]} for key, value in daily_values.items()} >>> daily_values {'Added sugars': {'value': 0, 'unit': 'g'}, 'Biotin': {'value': 0, 'unit': 'mcg'}}
Done. Can be found in the following branch: combined_nutrients_dict
Using a dict comprehension (love Python!), e.g.