0

Python Developer - Pancakes Exercise

This is the solution: #the list of breakfasts breakfasts = [ 'Donuts', 'Waffles', 'Yogurt', 'Burrito', 'Toast'] #index of the item to be replaced item = int(input()) #replace that item with "Pancakes" breakfasts[item] ='Pancakes' #display the updated list print(breakfasts) I do not understand how item 0, 3, and 4 were defined as Pancakes. Where is that info inside the code?

22nd Dec 2023, 12:30 AM
Marcus Bigtree
1 Resposta
+ 1
Hi, Marcus Bigtree ! When you input a number between 0 and 4, it will become the list index where the word ’Pancakes’ is assigned to. 4 -> breakfasts[4] = ’Pancakes’ -> [’Donuts’, …, ’Pancakes’ ]
22nd Dec 2023, 12:44 AM
Per Bratthammar
Per Bratthammar - avatar