I'm trying to create a for loop in a while loop and I need to break the outside while loop when idx = 3, but for some reason it doesn't work.
arr = [-1, -1, -1, -1, -1]
indices = [0, 1, 2, 3, 4]
idx = 0
while idx < 3:
    for item in indices:
        arr[item] = idx
        idx += 1
        print('idx', idx)
Expected output:
idx 1 idx 2 idx 3 
Actual output:
idx 1 idx 2 idx 3 idx 4 idx 5
Is there something I'm missing?
 
     
     
    