Solved

Delete Element from Array

  • 2 July 2020
  • 2 replies
  • 110 views

Hello All, I am new in this community and I am in learning face, I want to know the output syntax of deleting elements from an Array in Python. I have mention the input format but i don’t know about the final output. Can anyone suggest me.
 

import array as ar1  number = ar1.array('i', [11, 22, 33, 33, 44])  del number[2] # removes the third element  print(number)  del number # deletes the entire array  print(number)
icon

Best answer by rohanjoshi0894 13 July 2020, 17:25

Just review this code and if you want to know more about Python Array.

import array as arr

number = arr.array('i', [1, 2, 3, 3, 4])

del number[2] # removing third element
print(number) # Output: array('i', [1, 2, 3, 4])

del number # deleting entire array
print(number) # Error: array is not defined
View original

2 replies

Userlevel 7

I use google for such questions.

try this: https://www.google.com/search?q=delete+element+from+array+python

Just review this code and if you want to know more about Python Array.

import array as arr

number = arr.array('i', [1, 2, 3, 3, 4])

del number[2] # removing third element
print(number) # Output: array('i', [1, 2, 3, 4])

del number # deleting entire array
print(number) # Error: array is not defined

Reply