一、猜年纪
age = 18
x = 3
prize_dict ={
"1": "女朋友",
"2": "ps4pro",
"3": "s9世界赛决赛门票",
"4": "霍格沃兹入学通知书",
"5": "哆啦A梦",
"6": "皮卡丘",
"7": "核弹发射按钮",
"8": "潘多拉魔盒",
"9": "逝世亡笔记",
"10": "空想乡永久居住证"
}
while x > 0:
guess = input("猜猜我的年纪>>> ").strip()
if not guess.isdigit():
print("好好说个数字啦!")
continue
guess = int(guess)
if guess > age:
if x != 1:
x -= 1
print(f"猜大啦!你还有{x}次机遇!")
while True:
answer = input("想持续玩吗?回复Y可以持续,回复N就直接退出啦!").lower()
if answer == "y":
break
elif answer == "n":
print("下次再来玩哦,再见啦!")
x = 0
break
else:
print("别乱回复鸭!")
print("输入Y或N就行啦!")
continue
print("还是猜大啦!没机遇咯!拜拜~~")
break
elif guess < age:
if x != 1:
x -= 1
print(f"猜小啦!你还有{x}次机遇!")
while True:
answer = input("想持续玩吗?回复Y可以持续,回复N就直接退出啦!").lower()
if answer == "y":
break
elif answer == "n":
print("下次再来玩哦!再见啦!")
x = 0
break
else:
print("别乱回复鸭!")
print("输入Y或N就行啦!")
continue
print("还是猜小啦!没机遇咯!拜拜~")
break
else:
if x == 3:
print("好利害啊,一次就猜对啦!")
elif x == 2:
print("恭喜你!猜对啦!")
else:
print("终究猜对啦!")
for i in range(2):
show = prize_dict.items()
for j in show:
print(j)
if i == 0:
choice_1 = input("选择一份奖品吧!不要的话也能够输入‘N’退出哦!").lower()
if choice_1 == "n":
print("呜呜呜~~一件爱好的都没有吗?")
break
if not choice_1 in prize_dict:
print("别乱输入鸭!")
print("输入奖品对应的数字就行啦!")
continue
prize1 = prize_dict[choice_1]
print(f"你的第一件奖品就是 {prize1} 啦!呐,请收好。")
prize_dict.pop(choice_1)
choice_2 = input("还能再选择一件哦,不想要了就输入‘N’吧。").lower()
if choice_2 == "n":
print("那就只要一件咯。")
break
if not choice_2 in prize_dict:
print("别乱输入鸭!")
print("输入奖品对应的数字就行啦!")
continue
prize2 = prize_dict[choice_2]
print(f"你的第二件奖品就是 {prize2} 啦,请收好哦")
break
print("游戏停止啦!下次再来玩吧!")
breakage = 18
x = 3
prize_dict ={
"1": "女朋友"