Python学习笔记-day1(while流程控制)

count = 0
while True:
    #print('count:',count)
    if count == 3:
        print('you guess over 3 times!fuck off!')
        break
    age = int(input('Please guess the lmc age:'))
    if age == 18:
        print('yes,you got it!')
        break
    elif age < 18:
        print('think bigger…')
    else:
        print('think smaller…')
    count=count+1

count = 0
while count < 3:
    #print('count:',count)
    age = int(input('Please guess the lmc age:'))
    if age == 18:
        print('yes,you got it!')
        break
    elif age < 18:
        print('think bigger…')
    else:
        print('think smaller…')
    count=count+1
else:#当while后条件不成立时执行
    print('you guess over 3 times!fuck off!')

<wiz_tmp_tag id="wiz-table-range-border" contenteditable="false" style="display: none;">

我的GitHub

我的QQ:28995141

我的E-mail:limich@aliyun.com

原文地址:https://www.cnblogs.com/limich/p/7474778.html