找回密码
 立即注册

扫一扫,访问微社区

QQ登录

只需一步,快速开始

查看: 1275|回复: 3

[求助] 入门-程序运行被标红,求解

0

主题

1

帖子

1

积分

贫民

积分
1
栀子花 发表于 2021-12-3 16:22:46 | 显示全部楼层 |阅读模式
本帖最后由 栀子花 于 2021-12-3 16:28 编辑

程序运行被标红,不会改,求指教
标红见图片,
运行代码如下:
import random
secret =random.randint(1, 100)
guess =0
tries =0

print("AHOY! I'm the dread pirate roberts, and i have a secret!")
print("it is a number from 1 to 100. i'll give you 6 tries.")

while guess !=(secret and tries < 6:
               guess = int(input("whatis yer guess?"))
               if guess < secret:
                  print("too low, ye scurvy dog!")
               elif guess > secret:
                   print("too high, landlubber!")

               tries = tries +1
if guess == secret:
         print("avast! ye got it! found my secrect, ye did!")
else:
    print("no more guesses! better luck next time, matey!")
    print("the secret number was", secret)

微信图片_20211203162750.jpg
回复

使用道具 举报

0

主题

1

帖子

1

积分

贫民

积分
1
栀子花  楼主| 发表于 2021-12-6 13:27:54 | 显示全部楼层
谢谢各位,去了括号运行成功了
回复 支持 1 反对 0

使用道具 举报

0

主题

956

帖子

956

积分

圣骑士

积分
956
sheeboard 发表于 2021-12-3 20:29:26 | 显示全部楼层
少个括号
回复

使用道具 举报

0

主题

1

帖子

1

积分

贫民

积分
1
wjgboy 发表于 2021-12-5 21:07:53 | 显示全部楼层
应该是多了一个括号吧  while guess !=(secret and tries < 6:    去掉这个语句中的括号再试试看
回复 支持 反对

使用道具 举报

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

本版积分规则

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