while函数未在python中的Else语句下执行

时间:2018-07-16 11:17:17

标签: python if-statement while-loop

 x=15
>>> if x==10:
    print ("not bad")
elif x==11:
    print ("good")
elif x==12:
    print ("best")
else:
    while x==30:
        x+=1
        print(x)

1 个答案:

答案 0 :(得分:2)

也许这就是您想要的吗?

x=15
>>> if x==10:
    print ("not bad")
elif x==11:
    print ("good")
elif x==12:
    print ("best")
else:
    while x < 30:
        x+=1
        print(x)