I have a list that contains some stuff similar to the below entry:
[[1, 'Potato', 2, 'Bag'], [2, 'Banana, 1, 'Bunch']].
These elements represent in order the item's UPC, Name, Quantity, and unit type. What I want to do is delete all the items at a certain index to change the list from the above to [[1, 'Potato', 2, 'Bag']]. I tried a couple of methods, but I either used them wrong or they weren't supposed to be used there (I used del, pop, and remove). How do I go about doing this?
del your_list[1]should have worked here, can you show what you tried and the error you got / how it was different from your expected output?your_list.pop(index). Please see How to Ask and the question checklist, and provide a minimal reproducible example[start_index: last_index]to an list. For example[1, 2, 3, 4, 5][:3]will produce[1, 2, 3]