judges = ["judge 1", "judge 2", "judge 3", "judge 4", "judge 5",]
couples = [1, 2, 3, 4, 5]
x=0
j=0
done = False
def judging(j, x, judges, couples,):
couplescores1 = []
couplescores2 = []
couplescores3 = []
couplescores4 = []
couplescores5 = []
print ("scoreing couple",couples[j],)
for i in couples:
print("score couples" ,couples[j],judges[x],"out of 30 minimum 1")
score = int(input( ": "))
couplescores[j].append(score)
x=x+1
j=j+1
if j == 5:
done = True
else:
x = 0
judging(j, x, judges, couples,)
judging(j, x, judges, couples,)
所以这是我的代码和我需要帮助的是追加我想要的是它的[j]被计算为它的整数,以便第一次它将得分保存到couplecores1然后不需要额外的长时间代码下一轮couplecores2和ect我知道我使用if和elif的陈述例如
if j == 0:
couplescores1.append(score)
elif j == 1:
couplescores2.append(score)
但是,如果可以,我想避免它
谢谢
答案 0 :(得分:0)
我不确定你想要什么,但我想我知道你想要做什么。我添加了一个列表,其中包含来自1-5的夫妇的分数couplescores
。然后我将那对夫妇的分数添加到列表中的相应位置,然后在最后打印它。
judges = ["judge 1", "judge 2", "judge 3", "judge 4", "judge 5",]
couples = [1, 2, 3, 4, 5]
couplescores = [0,0,0,0,0] # Holds scores for the couples 1-5
x=0
j=0
done = False
def judging(j, x, judges, couples,):
print ("Scoring couple",couples[j],)
for i in couples:
print("Score couples" ,couples[j],judges[x],"out of 30 minimum 1")
score = int(input(": "))
couplescores[j] = couplescores[j] + score # Adds the score to the list
x=x+1
j=j+1
if j == 5:
done = True
else:
x = 0
judging(j, x, judges, couples)
judging(j, x, judges, couples)
print(couplescores) # Prints scores