In Python, how does a for loop with `range` work?

前端 未结 6 1279
醉梦人生
醉梦人生 2021-01-03 19:20
for number in range(1,101): 
    print number

Can someone please explain to me why the above code prints 1-100? I understand that the range functio

6条回答
  •  梦毁少年i
    2021-01-03 19:33

    range is the list of the numbers 1 to 100.

    number then references each object in that list

提交回复
热议问题