How to remove values to a python array?

Hi, i need to know How to remove values to a python array

3 Likes

You can use the pop() or ‘remove()’ method.

1. pop() method

The pop() method takes the index to be removed as the parameter, and removes the element at that index from the calling array.

Syntax:

array_name.pop(index)

Example

If you want to delete the element at index 3 from the array myArray:

myArray.pop(4)

2. remove() method

The reomve() method takes the element to be removed as the parameter, and removes its first occurrence from the calling array.

Syntax:

array_name.remove(element)

Example

If you want to delete the element “bmw” from the array carsArray:

carsArray.remove("bmw")
1 Like