Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (50.2k points)
Can anyone tell me how to remove an element from a List in Python?

1 Answer

0 votes
by (107k points)

For removing any element from a List, you need to use an in-built function named pop(), it will help you to remove any index value element from your list:

l = list(range(10))

print(l)

Output:

[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

Now from this list, let’s say I want to eliminate 3, for that:

print(l.pop(3))

print(l)

Now the output is:

3

[0, 1, 2, 4, 5, 6, 7, 8, 9]

As you can see now, the 3rd index value element has been removed from the l list.

If you are looking for an online course to learn Python, I recommend this Python Training program by Intellipaat.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...