鱼C论坛

 找回密码
 立即注册
查看: 1626|回复: 2

求帮助

[复制链接]
发表于 2021-3-22 20:14:30 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
import random

times = 3
secret = random.random(1,10)

print("我是一个游戏")
guess = 0
print("猜一猜我心中的数字",end"")

while (guess !=secret) and (times>0):
    temp = input()

    if temp.isdigit():
        guess = int(temp)
        if guess == secret:
            print("答对了,干得不错.")
        else:
            if guess > secret:
                print("大兄弟,大啦")
            else:
                print("大兄弟,小啦")
            if times > 0:
                print("请再试一试.",end"")
            else:
                print("你是在弱了")
    else:
        print("类型输入错误,请重新输入",end"")
    times = times-1
print("游戏结束")
照着打语法也错误,难受
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2021-3-22 20:21:20 | 显示全部楼层
  1. import random


  2. times = 3
  3. secret = random.randint(1, 10)  # 不是 random 是 randint

  4. print("我是一个游戏")
  5. guess = 0
  6. print("猜一猜我心中的数字", end="")  # 逗号用英文的, 是 end = "" 不是 end ""

  7. while (guess != secret) and (times > 0):
  8.     temp = input()

  9.     if temp.isdigit():
  10.         guess = int(temp)
  11.         if guess == secret:
  12.             print("答对了,干得不错.")
  13.         else:
  14.             if guess > secret:
  15.                 print("大兄弟,大啦")
  16.             else:
  17.                 print("大兄弟,小啦")
  18.             if times > 0:
  19.                 print("请再试一试.", end="")  # 是 end = "" 不是 end ""
  20.             else:
  21.                 print("你是在弱了")
  22.     else:
  23.         print("类型输入错误,请重新输入", end="")  # 逗号用英文的, 是 end = "" 不是 end ""
  24.     times = times-1
  25. print("游戏结束")
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 1 反对 0

使用道具 举报

 楼主| 发表于 2021-3-22 22:28:48 From FishC Mobile | 显示全部楼层
谢了,老是粗心。
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-6-26 09:00

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表