pop in python lists not working | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

pop in python lists not working

1. Use the pop() function to pop out the item in position five of your shopping_cart list. shopping_cart = ['eggs','banana','grapes','bread','butter','rice','soup','meat','beans'] print(shopping_cart.pop(5)) Output:'rice' But my testing scenario not passed so please help me to understand the exact issue here?

17th Sep 2020, 5:56 AM
Abhi
Abhi - avatar
1 Answer
+ 4
Indexing starts from 0 so your fifth element is at index 4.
17th Sep 2020, 6:02 AM
Avinesh
Avinesh - avatar