+ 4
Remove only removes the first occurrence, so if there are more of that element in there, you'll only drop the first one. If you know the index, you can write: del your_list[that_index] If you want to pull out some item, so remove it and directly use it, you can write: x = your_list.pop(index)
30th Jan 2020, 1:26 PM
HonFu
HonFu - avatar
+ 4
Python has a remove command list.remove(element). Is this what you need?
30th Jan 2020, 12:41 PM
Black Winter
+ 1
myint = 4 # <- the number you want to be removed from list mylist = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 4] for x in range(mylist[:].count(myint)): mylist.remove(myint) print(mylist)
30th Jan 2020, 5:47 PM
rodwynnejones
rodwynnejones - avatar