我的程序每次输出选手的分数都是7,而不是选手的编号谁能帮我解决这个问题(程序还没有完全完成,我知道程序中还有其他错误的问题,请你只解决 "j不循环的问题",而不是其他问题)
numJudges = 7
numCompetitors = int(input("Enter number of competitors(between 3 and 16 inc)" ))
for comp in range(0,numCompetitors):
totalC = 0
print("input scores between 0 and 10 for each Judge")
for j in range(0, numJudges):
j = j+1
scoreJ = int(input("Score for judge"))
totalC = totalC + scoreJ
scoreC = totalC / numJudges
print("Score for competitor ", j ," is", scoreC)
j
不是你的参赛者的编号--是最后一个评委的ID。
你需要输出的是 comp
在最后一行代替。
print("Score for competitor ", comp ," is", scoreC)
你的最后一行应该是:print("Score for competitor ", comp+1 ," is", scoreC)