0

Create an array with 5 values & delete the value at index no. 2 without using in-built function???

from array import* arr = array('i', [12,45,78,56, 16]) for i in arr: if i==arr[2]: continue print(i) Can anyone tell me how 78 was deleted in the code??

18th Sep 2021, 11:58 AM
Priyanshu Patel
Priyanshu Patel - avatar
2 Answers
+ 1
Priyanshu Patel continue will skip current iteration and nothing will happen so here 78 will be skip but rest value will be print
18th Sep 2021, 12:14 PM
A͢J
A͢J - avatar
0
def Del(index,array): Arr=[] i=0 for x in array: if index!=i: Arr.append(x) i+=1 return Arr arr = [12,45,78,56, 16] arr = Del(2,arr) print(arr)
18th Sep 2021, 1:32 PM
SAN
SAN - avatar