Difference between remove() function and del statement
In : BSc IT Subject : Programming in Python`remove()` deletes the first occurrence of a specific value from a list and raises an error if the value is not found.
The `del` statement removes an item at a specific index or deletes the entire list. Use `remove()` when you know the value, and `del` when you know the index.
Example :
fruits = ["apple", "banana", "cherry"]
fruits.remove("banana")
print(fruits) # Output: ['apple', 'cherry']
fruits = ["apple", "banana", "cherry"]
del fruits[1]
print(fruits) # Output: ['apple', 'cherry']