Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Question: How to remove values from a Python array?
Answer:

The elements can be removed from a Python array using the remove() or pop() function. The difference between pop() and remove() will be explained in the below example.

Example of remove():

fruits = ['apple', 'banana', 'cherry']

fruits.remove('banana')

print(fruits)

Output:

['apple', 'cherry']

 

Example of pop():

fruits = ['apple', 'banana', 'cherry']

fruits.pop(1)

print(fruits)

Output:

['apple', 'cherry']
Is it helpful? Yes No

Most helpful rated by users:

©2025 WithoutBook