擅长:python、mysql、java
<p>试试这个:</p>
<pre><code>games=[("anna","ross"),("manny","maria"),("rita","joel")]
results=[(2,0),(1,3),(1,1)]
def calculateResult(x,y):
if(y[0]>y[1]):
return x[0]
elif(y[1]>y[0]):
return x[1]
else:
return "TIE"
res = []
for i in range(len(games)):
res.append(calculateResult(games[i],results[i]))
print(res)
</code></pre>
<p>在这里,我将列表、游戏和结果中的各个元组传递到一个函数中,该函数比较结果并相应地返回游戏的输出</p>