break continue

break will exit the entire loop

l=[3,4,5,6,7,8]

for i in l:

  if i ==5:

    break

  print(i)

3

4

continue to exit the current cycle

l=[3,4,5,6,7,8]

for i in l:

  if i ==5:

    continue

  print(i)

3

4

6

7

8

Another: inside and outside the loop variable can not be the same

 

Reproduced in: https: //www.cnblogs.com/eleni/p/11062703.html

Guess you like

Origin blog.csdn.net/weixin_34104341/article/details/93448717