0

Here's my code, What i wanted to do is completely remove 'banana' from list. CODE

thislist = ["apple", "banana", "cherry", "banana"]
thislist.remove("banana")
print(thislist)

OUTPUT

['apple', 'cherry', 'banana']
  • https://docs.python.org/3/tutorial/datastructures.html: "*list.remove(x): Remove the first item from the list whose value is equal to x.*" – Gino Mempin Jul 18 '21 at 21:23

1 Answers1

0

You could do

thislist = [item for item in thislist if item != "banana"]
DS.
  • 22,632
  • 6
  • 47
  • 54