0

a=[1,2,3,4,5] for i in a: a.remove(i) print(a)

How it actual executes

14th Oct 2024, 12:54 PM
Palagani akhila gowd
Palagani akhila gowd - avatar
1 ответ
+ 4
Palagani akhila gowd As the for loop executes 0 is elimated the 1 in the array and the array a becomes [2,3,4,5] The for loop i is now 1 so 3 will be elimated and the array a becomes [2,4,5] The for loop i is now 2 so 5 will be elimated and the array a becomes [2,4]
14th Oct 2024, 1:52 PM
BroFar
BroFar - avatar