码迷,mamicode.com
首页 > 编程语言 > 详细

python while循环

时间:2017-11-16 11:47:53      阅读:199      评论:0      收藏:0      [点我收藏+]

标签:put   pytho   div   pre   inpu   +=   print   guess   ==   

count = 0
answer = 10

while True:
    print(count)
    count += 1
    guess = int(input(‘猜一个‘))
    if guess == answer:
        print(‘ok‘)
        break
    elif guess > answer:
        print(‘猜大了‘)
    else:
        print(‘猜小了‘)

    if count ==10:
        break
print(‘第二个while‘)
count = 0
while count <3:
    count +=1
    guess = int(input(‘猜一个‘))
    if guess == answer:
        print(‘ok‘)
        break
    elif guess < answer:
        print(‘猜小了‘)
    else:
        print(‘猜大了‘)
else:
    print(‘机会用完了‘)

  

python while循环

标签:put   pytho   div   pre   inpu   +=   print   guess   ==   

原文地址:http://www.cnblogs.com/jackadam/p/7842700.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!