python 猜数字小游戏 进阶版
import randomcounts = 3
numeral = random.randint(1,10)
while counts > 0:
temp = input("不妨猜一猜小甲鱼现在心里想的是哪个数字:")
guess = int(temp)
if guess == numeral:
print("你是小甲鱼的蛔虫吗?")
print("哼!猜中了也没奖励。")
break
else:
if guess < numeral:
print("小了,只有三次机会哦")
else:
print("大了,只有三次机会哦")
cs = str(counts-1)
print("你还剩下" + cs + "机会")
counts = counts-1
print("游戏结束,不玩了")
怎么样才能结束时不自动退出?
页:
[1]