Delete an Item from the List in Python

Source code :

# prepare a list

fruits = ['apple', 'bananas', 'grapes', 'strawberries']
print("Before delete: ",fruits)

#deleting the third item(grapes) from the list

del fruits[2]
print("After delete: ",fruits)


Output :

Before delete:  ['apple', 'bananas', 'grapes', 'strawberries']
After delete:  ['apple', 'bananas', 'strawberries']

Notes :

A List's index starts from Zero, So the index of third item(grapes) is Two.


Output :


                

Comments :