Python for loop?

前端 未结 6 1524
醉酒成梦
醉酒成梦 2021-01-24 10:04

I am having trouble understanding a Python for loop. For example, here is some code I\'ve made while I\'m learning:

board = []
for i in range (0,5):
    board.ap         


        
6条回答
  •  醉话见心
    2021-01-24 10:46

    In c/java the for loop wiil be:

    for(int i=0;i<=10;i++)
    { 
      //for-loop-body
    }
    

    here for every iteration i will be incrementing +1 value till i reaches 10, after that it comes out of loop. In same way,in python the for loop looks like:

    for i in range(0,10):
      //for-loop-body
    

    here i performs same operation and i is just a variable to increment a value.

提交回复
热议问题