Python Developer - Pancakes Exercise | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
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