|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
import random
daan = random.randint(1,2)
cishu = 3
temp = int(input("请输入一个数字:"))
while (temp != daan) and (cishu > 0):
temp = int(input(" 猜错了重新猜吧"))
cishu = cishu - 1
if temp == daan:
print("猜对了")
cishu = cishu - 3
else:#
if temp > daan:#
print("大了大了")
else:
print("小了小了")
cishu = cishu - 1#
print("游戏结束不玩了")
如果第一次就猜中的话 我想打印一句话不知道应该加在什么地方 求助!
直接加个 if 就好~
- import random
- daan = random.randint(1,2)
- cishu = 3
- temp = int(input("请输入一个数字:"))
- if temp == daan:
- print('太强了!第一次就猜中了')
- while (temp != daan) and (cishu > 0):
- temp = int(input("猜错了重新猜吧"))
- cishu = cishu - 1
- if temp == daan:
- print("猜对了")
- cishu = cishu - 3
- else:#
- if temp > daan:#
- print("大了大了")
- else:
- print("小了小了")
- cishu = cishu - 1#
- print("游戏结束不玩了")
复制代码
|
|