New course! Every coder should learn Generative AI!
Try a free lesson+ 1
Why do I get TypeError: 'builti_function_or_method' object is not subscriptable in row 2?
You decided to create a list of fruits to buy and one item was wrong in the list. Remove the wrong item and print the new list. fruits = ['apple', 'orange', 'cucumber', 'mango', 'pineapple'] removed_fruit = fruits.remove[2] print(fruits) print(removed_fruit)
2 Answers
+ 1
.remove() uses the value you want to remove, not the index.
To delete an item using its index use the del() function.
https://www.w3schools.com/JUMP_LINK__&&__python__&&__JUMP_LINK/gloss_python_remove_list_items.asp
+ 1
Thank you Simon Sauter