试图让这个程序为一个学校项目工作,但在代码的第26行,我得到了一个不支持的操作数类型错误'int'和'str'。任何帮助都将不胜感激。代码如下:
final = False
while final == False:
while True:
try:
eventName = str(input("What is the event's name? "))
numberJudges = int(input("How many judges are there? "))
competitorName = str(input("What is the competitor's name? "))
judgeScores = input("Please enter the judges scores with a space between each one. ")
break
except ValueError:
print("That is not a valid name or number(s)")
finalJudges = numberJudges - 2
def judgeScoreListFunction(judgeScores):
judgeScoreList = judgeScores.split()
return judgeScoreList
def cleanJudgeScoresFunction(judgeScoreList):
judgeScoreList.remove(max(judgeScoreList))
judgeScoreList.remove(min(judgeScoreList))
finalJudgeScores = judgeScoreList
return finalJudgeScores
def cleanScoreFunction(finalJudgeScores, finalJudges):
cleanedScore = sum(finalJudgeScores)
finalScore = cleanedScore / finalJudges
format(finalScore, '.2f')
return finalScore
judgeScoreList = judgeScoreListFunction(judgeScores)
finalJudgeScores = cleanJudgeScoresFunction(judgeScoreList)
finalScore = cleanScoreFunction(finalJudgeScores, finalJudges)
if competitorName == "Finish":
final = True
而不是:
你想要:
我还建议去掉所有这些小的单用途函数。你知道吗
相关问题 更多 >
编程相关推荐