-2

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?

1 Answers1

1

del works for your example

>>> data = [[1, 'Potato', 2, 'Bag'], [2, 'Banana', 1, 'Bunch']]
>>> del data[1]
>>> data
[[1, 'Potato', 2, 'Bag']]
tdelaney
  • 73,364
  • 6
  • 83
  • 116