gpt4 book ai didi

python - 类型错误 : '>=' not supported between instances of 'int' and 'str' even with adding int to the front of score

转载 作者:太空宇宙 更新时间:2023-11-03 14:23:00 24 4
gpt4 key购买 nike

score = int(0)
name = str(input("What is your name?"))
print("Hello " + name + "!")
pi = input( name + ", can you tell me the value of pi? ")

if score >= '6' :
print ("congratulations, " +name + " you passed the exam! You'll be richer than your wildest dreams!" )
else:
print: ("Listen, " +name + " you screwed up big time, with grades like this you'll be stuck working in a Best Buy for the rest of your life")

问题是 if Score 语句,这就是我收到错误的地方。我需要对这个“测验”进行评分。我整晚都在研究这个问题,我不是一个好的程序员。请帮助我

提前谢谢

最佳答案

您正在比较int(分数)与string('6')。尝试:

if score > 6: # <--omit the quotes
etc...

关于python - 类型错误 : '>=' not supported between instances of 'int' and 'str' even with adding int to the front of score,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47828175/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com