码迷,mamicode.com
首页 > 其他好文 > 详细

while循环初探

时间:2017-09-30 16:22:18      阅读:173      评论:0      收藏:0      [点我收藏+]

标签:while循环   mes   hat   please   big   游戏   enter   else   while   

 1 count = 0
 2 #while True:
 3 while count < 3:
 4     count +=1           #count每次加1
 5     guess_number = int(22)
 6     get_number = int(input(Please enter the number you guessed>>>))
 7 
 8     if guess_number == get_number:
 9         print("Congratulations, you guessed it")
10         exit()
11     elif guess_number > get_number:
12         print("The number you guessed is too small")
13     else:
14         print("The number you guessed is too big")
15 else:
16     print(too many times)  #上面条件不满足的时候打印

 #while 更改版超过三次询问是否继续游戏

 1 count = 0
 2 while True:
 3     guess_number = int(22)
 4     get_number = int(input(Please enter the number you guessed>>>))
 5 
 6     if guess_number == get_number:
 7         print("Congratulations, you guessed it")
 8         exit()
 9     elif guess_number > get_number:
10         print("The number you guessed is too small")
11     else:
12         print("The number you guessed is too big")
13     count += 1
14     if count == 3:
15         a = input("You guessed it three times.Do you want to continue playing this game?[N/Y]")
16         if a == n:
17             print(That is a pity!!)
18             exit()
19         else:
20             count = 0
21             continue

 

while循环初探

标签:while循环   mes   hat   please   big   游戏   enter   else   while   

原文地址:http://www.cnblogs.com/jesse-gong/p/7615148.html

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