cancel
Showing results for 
Search instead for 
Did you mean: 

Delete Element from Array

Delete Element from Array

aartiyadav
New Contributor

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)
1 ACCEPTED SOLUTION

rohanjoshi0894
New Contributor

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 solution in original post

2 REPLIES 2

rohanjoshi0894
New Contributor

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

Zdeněk_Pala
Extreme Employee

I use google for such questions.

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

Regards Zdeněk Pala
GTM-P2G8KFN