How Can We Help?
Introduction:
In this tutorial, we are going to explain how to use Python list remove() Method with basic syntax and many examples for better understanding.
Python list remove() method. Searches for the passed element in the list and removes the first matching element of passed element from the list.
Syntax:
<list_variable_name>.remove(object)
Input Parameters:
- object : is a single element which to be removed from the list.
- list_variable_name : The lists that we want to count a particular element inside.
Return Value:
Python list remove() method doesn’t return any value (returns None).
Example
# Alphabet List alphabet=['a', 'b', 'c', 'd'] # Remove 'b' character from alphabet list alphabet.remove('b') # Print updated alphabet list print("Updated alphabet list: ",alphabet)
Example output
Updated alphabet list: [‘a’, ‘c’, ‘d’]
In the above example, element ‘b’ remove from a list variable ‘alphabet’ by ” alphabet.remove(‘b’)” and returns updated list.
In this tutorial, you have learned how to remove the first matching element of passed element from the list by using Python list count() method.
Hopefully, it was clear and concise.
If you have an inquiry or doubt don’t hesitate to leave them in the comment section. we are waiting for your feedback.
Similar Python list Methods:
- list.append(object) : It appends object to the given list.
- list.extend(seq) : It appends the contents of sequence to the list.
- list.count(object) : It returns count of how many times object occurs in the list.
- list.index(object) : It returns the lower index value of passed object in the list, if object is present in the list.
- list.insert(index,object) : It inserts object into the list at offset index.
- list.pop(obj=list[-1]) : It removes last object from the list and returns removed object of a list.
- list.reverse() : It reverses objects of list in place.
- list.sort([func]) : It sorts objects of a list and use compare func, if given.
Python tutorials list:
- Python tutorials list : access all python tutorials.