Data Structure Part 1-b

 

#pop():- This function removes the element at the position mentioned in its argument and returns it.
#remove():- This function is used to remove the first occurrence of the value mentioned in its arguments.

import array
arr=array.array("i",[1,2,3,1,4,5])
print("The new created array is :",end=" ")
for i in range(0,6):
print(arr[i],end=" ")
print("\r")
print ("The popped element is : ",end="")
print(arr.pop(1))
# printing array after popping
print ("The array after popping is : ",end="")
for i in range(0,5):
print(arr[i],end=" ")
print("\r")
print(arr.remove(1))
# printing array after removing
print ("The array after removing is : ",end="")
for i in range(0,4):
print(arr[i],end=" ")

Comments