# 需求:猜測Sun的女朋友的年齡.
# 中間任意一次猜對,游戲通關結束
# 猜錯3次,問是否還要繼續。
# 如果繼續,可繼續猜測3次,以此回圈;
# 如果停止,則游戲退出;
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author:Bell Sun
age_of_Sun_gf = 25
i = 0
print(type(i))
for i in range(4):
guess_age_of_Sun_gf = int(input("Please input Bell Sun's girlfriend age:"))
if age_of_Sun_gf == guess_age_of_Sun_gf:
print("Your guess is right !")
break
elif age_of_Sun_gf < guess_age_of_Sun_gf:
print("Your guess is too big !")
else:
print("Your guess is too low !")
print("i =", i)
while i == 3:
guess_continue = input("if you want to continue guess , please don't press 'n' .")
print("this")
if guess_continue != 'n':
i = 0
print("i =", i)
else:
print("See you next time !")
uj5u.com熱心網友回復:
我覺得while在外面來判定游戲是否結束,然后用一個flag判斷次數就好轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/177178.html
上一篇:如圖,模塊沒錯,想知道怎么解決
下一篇:關于memoryerror
