• + 1 comment

    range(x,y) will create a range of elements from x to y-1 if only one parameter is passed x is assumed to be 0 so range(y) will create elements in range from 0 till y-1

    so here range(4) will create a range which includes 0,1,2,3 hence the loop will iterate 4 times as there are 4 elements