Python Program to remove an element from a list ( Using filter() method)

bookmark

# Python program to remove an element from a list using the filter() method  
my_list = [1, 2, 3, 4, 5]  
my_list = list(filter(lambda x: x != 3, my_list))  # Removes the element 3 from the list  
print(my_list)    


Output:

[1, 2, 4, 5]