search

Home  >  Q&A  >  body text

python - How to jump out of for loop, seems to be dizzy

h = ['hp','op']


for x in ['POP','PHP','PYTHON']:
    for y in h:
        if y in x:
            continue #如果这个跳出循环 ,下一句就不会print
    print x 

My understanding is to jump directly out of the outermost for loop, but why is it not like this?

伊谢尔伦伊谢尔伦2720 days ago796

reply all(1)I'll reply

  • 我想大声告诉你

    我想大声告诉你2017-06-22 11:54:06

    continue only jump out of the nearest (or innermost) loop , that is, the inner for.

    reply
    0
  • Cancelreply