Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Python Delete List Elements

# Deleting list items
my_list = ['p', 'r', 'o', 'b', 'l', 'e', 'm']

# delete one item
del my_list[2]

print(my_list)

# delete multiple items
del my_list[1:5]

print(my_list)

# delete the entire list
del my_list

# Error: List not defined
print(my_list)
Source by alexandra-zaharia.github.io #
 
PREVIOUS NEXT
Tagged: #Python #Delete #List #Elements
ADD COMMENT
Topic
Name
1+5 =