Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

discard vs remove python

list = [1, 2, 3, 4, 5]
list.remove(0)	//removes element in specified position
print(list)
>> [2, 3, 4, 5]
list.discard(2)	//discards element if found in iterable (in list in this case) ;)
print(list)
>> [3, 4, 5]
 
PREVIOUS NEXT
Tagged: #discard #remove #python
ADD COMMENT
Topic
Name
7+8 =