I have JSON data looks like this:
data2 = [{'name': '', 'steps': [{'number': 1, 'step': 'Place olive oil on the bottom of your Instant Pot before adding chicken breasts to the Instant Pot.', 'ingredients': [{'id': 4053, 'name': 'olive oil', 'image': 'olive-oil.jpg'}], 'equipment': [{'id': 414093, 'name': 'instant pot', 'image': ''}]}, {'number': 2, 'step': 'Season chicken breast with salt and pepper.', 'ingredients': [{'id': 1102047, 'name': 'salt and pepper', 'image': 'salt-and-pepper.jpg'}], 'equipment': []}, {'number': 3, 'step': 'Close Instant Pot and make sure the pressure gauge is turned to seal. Set pressure to manual, high pressure and set the timer for 8 minutes. Pressure will build and then the timer will start.', 'ingredients': [], 'equipment': [{'id': 414093, 'name': 'instant pot', 'image': ''}, {'id': 404695, 'name': 'kitchen timer', 'image': 'kitchen-timer.jpg'}], 'length': {'number': 8, 'unit': 'minutes'}}, {'number': 4, 'step': 'When the timer goes off, quick release the Instant Pot by turning pressure gauge to vent. When pressure releases shred chicken breast in the Instant Pot and serve any way you like.', 'ingredients': [], 'equipment': [{'id': 414093, 'name': 'instant pot', 'image': ''}, {'id': 404695, 'name': 'kitchen timer', 'image': 'kitchen-timer.jpg'}]}]}]
And I want to get the number and step, so that my output print looks like this:
1 Place olive oil on the bottom of your Instant Pot before adding chicken breasts to the Instant Pot.
2 Season chicken breast with salt and pepper.
3 Close Instant Pot and make sure the pressure gauge is turned to seal. Set pressure to manual, high pressure and set the timer for 8 minutes. Pressure will build and then the timer will start.
4 When the timer goes off, quick release the Instant Pot by turning pressure gauge to vent. When pressure releases shred chicken breast in the Instant Pot and serve any way you like.
My current code looks like:
for item in data2[0]['steps']:
print(item['step'])
And this only prints out all the steps but not the number. How can I print out the value of "number" also?
print(f"{item['number']} {item['step']}")print(item['number'], item['step'])for item in data2[0]['step']to get access to each item...