|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
import random
secret =random.randint(1,10)
temp = input("计算机现在在想什么数字呢?:")
guess = int(temp)
times=1
while (guess != secret) and (times < 3) :
if guess > secret:
print("兄弟,猜小了")
else:
print("兄弟,猜大了")
temp = input("再试试吧~")
guess = int(temp)
times = times + 1
if (times<=3) and (guess == secret):
print("你猜对了喔~")
print("不过没奖励~")
else:
print("哎呀,三次机会都没猜到,不跟你玩了~")
运行后是这样的:计算机现在在想什么数字呢?:1
兄弟,猜大了
再试试吧~11
兄弟,猜小了
再试试吧~10
哎呀,三次机会都没猜到,不跟你玩了~
问题出在这里
- if guess > secret:
- print("兄弟,猜小了")
- else:
- print("兄弟,猜大了")
复制代码
|
|