Scoping in Python 'for' loops

前端 未结 6 1275
名媛妹妹
名媛妹妹 2020-11-22 03:52

I\'m not asking about Python\'s scoping rules; I understand generally how scoping works in Python for loops. My question is why the design decisions were m

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-22 04:36

    If you have a break statement in the loop (and want to use the iteration value later, perhaps to pick back up, index something, or give status), it saves you one line of code and one assignment, so there's a convenience.

提交回复
热议问题