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.
list.remove()
This strategy expels first event given component from the rundown.
Syntax:
list.remove(element)
Here,
- 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.
Example:
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]
Program:
# 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])
Output:
List element:
10
20
30
40
30
List element after removing 30:
10
20
40
30