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

笨办法33while循环

时间:2017-12-28 23:30:37      阅读:162      评论:0      收藏:0      [点我收藏+]

标签:自己   eal   int   and   blog   odi   else   span   print   

改了之前的代码,加入while:

 1 #coding: utf-8
 2 print("王小狗丑不丑?丑→1;不丑→2")
 3 answer = input(">")
 4 if answer == "1":
 5     print("恭喜你,你的选择很正确!")
 6 
 7 elif answer == "2":
 8     print("要不,你再考虑一下? ")
 9     print("王小狗究竟丑不丑?丑→1;不丑→2")
10     real_answer = input(">")
11     while real_answer != "1" and real_answer != "2" :
12         print("别捣乱!王小狗丑不丑?丑→1;不丑→2")
13         real_answer = input(">")
14     while real_answer == "2" or real_answer != "1":
15         print("我觉得差不多了,你就说王小狗到底丑不丑?丑→1;不丑→2")
16         real_answer = input(">")
17         if real_answer == "2":
18             print("说这种话,你自己信吗!")
19         elif real_answer == "1":
20             pass
21         else:
22             print("请你认真回答。")
23     print("恭喜你,可以去睡觉了!")
24 
25 else:
26     print("不好好做题,你想作甚王小丑!")
27     print("请重新回答,王小狗丑不丑?丑→1;不丑→2")
28     last_answer = input(">")
29     while last_answer != "1" and last_answer != "2":
30         print("快回答!王小狗丑不丑?丑→1;不丑→2")
31         last_answer = input(">")
32     while last_answer == "2" or last_answer != "1":
33         print("无论如何,王小狗丑不丑?丑→1;不丑→2")
34         last_answer = input(">")
35         if last_answer == "2":
36             print("不能因为你的善良而埋没了良知!")
37         elif last_answer == "1":
38             pass
39         else:
40             print("你踏马好好回答行不行?")
41     print("恭喜你,可以去睡觉了!")
42 
43 input()

 

笨办法33while循环

标签:自己   eal   int   and   blog   odi   else   span   print   

原文地址:https://www.cnblogs.com/p36606jp/p/8137891.html

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