Python list remove

In this article, you’ll see how to remove an element from a list in Python. The remove method is used to remove an element from a list. The remove method takes only one argument. The argument can be integer, string, or float. I highly recommend you get the “Python Crash Course Book” to learn Python.

Example 1: Remove an integer from a list

a = [10, 25, 35, 40, 70]
a.remove(40)
print(a)

Output:

[10, 25, 35, 70]

Example 2: Remove a string from a list

a = ['AI', 'ML', 'DL']
a.remove('DL')
print(a)

Output:

['AI', 'ML']

Example 3: Remove a float

a = [5.6, 3.5, 4.3, 6.7, 9.2]
a.remove(3.5)
print(a)

Output:

[5.6, 4.3, 6.7, 9.2]

Leave a Comment

Your email address will not be published.