while
Posted 雨之愿风
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了while相关的知识,希望对你有一定的参考价值。
- while break:
count = 0 while True: count +=1#count = count + 1 print(count) if count == 100: break
- while 条件
while count < 3 : #注意这里需要: guest_age = int(input("guess age:")) if guest_age == age_of_oldboy : print("yes! you got it") break #跳出循环 elif guest_age > age_of_oldboy : print("you guess too bigger") else: print("you guess too small") count +=1 #count = count + 1
- while else
格式:
while 条件:
print()
else:
print()
while count < 3 : #注意这里需要: guest_age = int(input("guess age:")) if guest_age == age_of_oldboy : print("yes! you got it") break #跳出循环 elif guest_age > age_of_oldboy : print("you guess too bigger") else: print("you guess too small") count +=1 #count = count + 1 else: print("you guess too much !Fuck !")
以上是关于while的主要内容,如果未能解决你的问题,请参考以下文章