+ 3
How delete element of list?
I want to write the code, which of the list will delete the element. Help me figure out why my code does not work, or suggest your own code. https://code.sololearn.com/chiU3zOeMYRg/?ref=app
5 Antworten
+ 8
Yep, the best to use filter.
If not:
l = [1, 1, 3, 2, 1, 3]
del_element = 1
while del_element in l:
l.remove(del_element)
print(l)
>>>
[3, 2, 3]
+ 7
l.remove(1)
+ 5
What do you want to delete exactly? One element of a given index or *all* elements equal to a given value?
+ 3
I found the answer using the lambda function)))
https://code.sololearn.com/cpHy5X7itX24/?ref=app
+ 2
I want to delete all items that are equal to 1