0

list.remove(obj)

if there are many same type objects in the list which 1 will it remove?

19th Feb 2018, 10:55 AM
Pradeep Vc
Pradeep Vc - avatar
4 Answers
+ 5
Which programming language?
19th Feb 2018, 11:20 AM
Fox
Fox - avatar
+ 3
# It will remove the first one. # The code below will return [ 'b', 'c', 'a' ] L = [ 'a', 'b', 'c', 'a' ] L.remove('a') print(L) # If you want to remove ALL instances of an element, see the code-example below. # It will return [ 1, 2, 4, 5 ] L = [ 1, 2, 4, 3, 3, 5, 3 ] L = list(filter(lambda x : x != 3, L)) print(L)
21st Feb 2018, 9:03 AM
Fox
Fox - avatar
+ 1
py
19th Feb 2018, 11:54 AM
Pradeep Vc
Pradeep Vc - avatar
0
is it possible to remove all same type objects with remove? without any additional logic
19th Feb 2018, 6:40 PM
Pradeep Vc
Pradeep Vc - avatar