笨办法33while循环

时间:2023-03-08 16:55:21

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

 #coding: utf-8
print("王小狗丑不丑?丑→1;不丑→2")
answer = input(">")
if answer == "":
print("恭喜你,你的选择很正确!") elif answer == "":
print("要不,你再考虑一下? ")
print("王小狗究竟丑不丑?丑→1;不丑→2")
real_answer = input(">")
while real_answer != "" and real_answer != "" :
print("别捣乱!王小狗丑不丑?丑→1;不丑→2")
real_answer = input(">")
while real_answer == "" or real_answer != "":
print("我觉得差不多了,你就说王小狗到底丑不丑?丑→1;不丑→2")
real_answer = input(">")
if real_answer == "":
print("说这种话,你自己信吗!")
elif real_answer == "":
pass
else:
print("请你认真回答。")
print("恭喜你,可以去睡觉了!") else:
print("不好好做题,你想作甚王小丑!")
print("请重新回答,王小狗丑不丑?丑→1;不丑→2")
last_answer = input(">")
while last_answer != "" and last_answer != "":
print("快回答!王小狗丑不丑?丑→1;不丑→2")
last_answer = input(">")
while last_answer == "" or last_answer != "":
print("无论如何,王小狗丑不丑?丑→1;不丑→2")
last_answer = input(">")
if last_answer == "":
print("不能因为你的善良而埋没了良知!")
elif last_answer == "":
pass
else:
print("你踏马好好回答行不行?")
print("恭喜你,可以去睡觉了!") input()

精简:

 #coding: utf-8
print("王小狗丑不丑?丑→1;不丑→2")
answer = input(">")
while answer !='':
if answer=='':
print("回答错误,请重新输入")
else:
print("别瞎搞,好好回答")
answer = input(">")
print("恭喜你,答对了!")
input()

注:因为是做给人玩的小游戏,导出exe文件,结尾input(),使运行框不关闭