Header Ads

Responsive Ads Here

Methods to delete data from the lists

 Methods to Delete Data from the Lists



string = ["string1", "string2", "string3","string2", "string4"]

# pop
string.pop()   # By default removes the last value
print(string)
# remove
string.pop(2)   # Removes the value at the given postion
print(string)

string.remove("string2")   # Removes the given value
print(string)
#del
del string[1]   # Removes the value at the given postion
print(string)

Powered by Blogger.