The user can use the remove() function to delete a specific object in the list.
Example:
- list_1 = [ 3, 5, 7, 3, 9, 3 ]
- print(list_1)
- list_1.remove(3)
- print(“After removal: “, list_1)
Output:[3, 5, 7, 3, 9, 3] After removal: [5, 7, 3, 9, 3]
If you want to delete an object at a specific location (index) in the list, you can either use del or pop.
Example:
- list_1 = [ 3, 5, 7, 3, 9, 3 ]
- print(list_1)
- del list_1[2]
- print(“After deleting: “, list_1)
Output:[3, 5, 7, 3, 9, 3] After deleting: [3, 5, 3, 9, 3]