Python for loop?

前端 未结 6 1518
醉酒成梦
醉酒成梦 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:25

    It's an unused variable. Python syntax requires a variable in that position, but you don't do anything with it since you simply want to repeat an action 5 times.

    Some people prefer the convention of naming an unused variable like this _:

    for _ in range(5)
    

    but this name can interfere with gettext.

提交回复
热议问题