python while循环
Posted 上官飞鸿
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python while循环相关的知识,希望对你有一定的参考价值。
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循环的主要内容,如果未能解决你的问题,请参考以下文章