在 python 中获取 TypeError: '>' not supported between 'str' and 'int' [closed]

Getting a TypeError: '>' not supported between instances of 'str' and 'int' in python [closed]

提问人:average npc 提问时间:11/18/2023 最后编辑:William Milleraverage npc 更新时间:11/21/2023 访问量:52

问:


编辑问题以包括所需的行为、特定问题或错误以及重现问题所需的最短代码。这将帮助其他人回答这个问题。

5天前关闭。

这篇文章在 5 天前被编辑并提交审核,未能重新打开帖子:

原始关闭原因未解决

我在尝试编写程序时遇到了这个错误,无论我做什么,它都不会消失。关于如何解决这个问题的任何建议?

# This code will serve as the basis of a school grading system
# Task 1
# First we will implement the arrays we are going to use in our 
# program along with all the variables/constants we shall need
ClassSize = 10
SubjectNo = 4

"StudentName" == ["Thomas", "Emily", "Mary", "Thomas", "Bob", 
                   "Jacob", "James", "Ali", "Fatime", "Raj"]
"StudentMark" == [[55, 35, 20, 60],
                  [60, 70, 45, 45],
                  [60, 45, 35, 20],
                  [45, 38, 61, 47],
                  [69, 52, 31, 68],
                  [23, 42, 63, 28],
                  [70, 68, 59, 62],
                  [43, 23, 54, 67],
                  [70, 70, 70, 70],
                  [65, 43, 70, 23]]
index_variable = "Student name"
element = "StudentMark"[index_variable]

"distinction" == 0
"merit" == 0
"Pass" == 0
"Fail" == 0
"Subject high" == 70
"Suject low" == 0
"Total per student" == 0

# Task 2
# Here we will write the code that actually calculates 
# the grades and the averages and percentages
"StudentName" == str(input("Enter a name: "))

if "Studentmark" == "70":
    grade = "distinction"
    "distinction" == "distiction" + "1"
elif "Studentmark" > "55":
        grade = "merit"
        "merit" == "merit" + "1"
elif "Studentmark" > "40":
            grade = "Pass"
            "Pass" == "Pass" + 1
else: grade = "Fail" and "Fail" == Fail + 1

评论

4赞 John Gordon 11/18/2023
不要让我们从图像中重新输入您的代码。请以纯文本形式发布代码和完整的错误回溯消息。
0赞 Cid 11/18/2023
"Studentmark"是字符串,而不是变量名称
0赞 rioV8 11/18/2023
不要引用变量名称,这不是赋值==
1赞 Karl Knechtel 11/21/2023
代码存在多个问题,所有这些问题都必须作为单独的问题来询问,其中大多数将被视为错别字,或者至少不是可以帮助其他人的连贯问题的基础。没有提供完整的错误消息;如果它被修复,其余的代码仍然是无稽之谈,离解决问题还差得很远。这个问题绝对不应该重新讨论。

答: 暂无答案