OneBite.Dev - Coding blog in a bite size

remove item from array in python

Code snippet on how to remove item from array in python

  my_arr = ["a", "b", "c", "d"]
  my_arr.remove("c")
  print(my_arr)

This code snippet uses a built-in method to remove an item from an array. First, we create an array called “my_arr” and define it with four elements (“a”, “b”, “c”, and “d”). Then, we use the array’s “remove()” method to remove the element “c” from it. Finally, we print the array to see the result which is [“a”, “b”, “d”]. The result shows that the element “c” has been removed from the array.

python