Here, we will figure out how to expel the first event of a given component in the rundown in Python. To expel a component from the rundown, we use list.remove(element).
Python program to evacuate the first event of a given component in the rundown: Given a rundown of the components and we need to expel the first event of a given component.
This strategy expels first event given component from the rundown.
- the list is the name of the rundown, from where we need to evacuate the component.
- component a component/article to be expelled from the rundown.
Input : list [10, 20, 30, 40, 30] function call to remove 30 from the list: list.remove(30) Output: List elements after removing 30 list [10, 20, 40, 30]
# Declaring a list list = [10, 20, 30, 40, 30] # print list print "List element:" for l in range(len(list)): print (list[l]) # removing 30 from the list list.remove(30); # print list after removing 30 print "List element after removing 30:" for l in range(len(list)): print (list[l])
List element: 10 20 30 40 30 List element after removing 30: 10 20 40 30