美文网首页
break and continue

break and continue

作者: 苗_a | 来源:发表于2018-07-21 15:53 被阅读8次

    for的循环

    name = 'dongGe'
    for x in name:
    print('----')
    print(x)

    带有break的循环

    name = 'dongGe'
    for x in name:
    print('----')
    if x == 'g':
    break
    print(x)

    while的循环

    i = 0
    while i<10:
    i = i+1
    print('----')
    print(i)

    带有break的循环

    i = 0

    while i<10:
    i = i+1
    print('----')
    if i==5:
    break
    print(i)#

    continue的循环

    for的循环 name = 'dongGe'

    for x in name:
    print('----')
    if x == 'g':
    continue
    print(x)
    i = 0

    while i<10:
    i = i+1
    print('----')
    if i==5:
    continue
    print(i)

    break和continue举列子

    用break求素数

    VirtualBox_Ubuntu_21_07_2018_15_41_19.png

    用continue执行

    Image.png

    相关文章

      网友评论

          本文标题:break and continue

          本文链接:https://www.haomeiwen.com/subject/ctphmftx.html