educative.io

Items[i][1] = 2 shouldn't be items[i] why the [1]

Shouldn’t there be just items[i] as the slice in the for range construct

Hello @Hiba,

items is essentially a slice of maps (we can also look at it as an array of maps). Hence, assigning 2 to items[i] will over write the map at index i. The value will also be lost in the next iteration. So first we index into the map location i.e. i and then we assign the value of 2 with key 1 to that particular map.

Hope this helps!