改写小游戏,实现
print("------------biolxy---------------")
temp = input("猜一下我心里想的是那个数:")
guess = int(temp)
times = 2
while (guess !=8) and (times > 0):
print("剩余次数" ,times)
guess = int(temp)
if guess == 8 and times ==1:
print("卧槽,这都能猜中")
else:
if guess ==8 and times != 0:
print("勉强算过了")
else:
if guess > 8:
print("不对,不对,大了大了!")
times = times - 1
else:
print("哎哎,又小了小了")
times = times -1
temp = input("猜错了,再来一次吧:")
if times ==2:
print("咱俩心有灵犀啊,一下就猜对了^_^!")
else:
print("游戏结束,再见!")
如果在前面插入一下代码 ,
import random
secret = random.randint(1,10)