基本上,我有两支球队的首发阵容,并且正在使用一个简单的公式,涉及每个球员的进攻和防守等级来确定得分。我计划随着时间的推移扩大这一点,显然让分数有所不同,并不总是一样;但是,现在我只想弄清楚我不断收到的错误。
这是代码:
#Player Database
#Player = [OR,DR]
#Miami Heat
Chris_Bosh = [114-90,103-100]
Udonis_Haslem = [110-90,103-100]
Lebron_James = [125-90,101-100]
Dwayne_Wade = [112-90,103-100]
Mario_Chalmers = [110-90,104-100]
#San Antonio Spurs
Tim_Duncan = [107-90,95-100]
Tiago_Splitter = [118-90,100-100]
Kawhi_Leonard = [114-90,99-100]
Manu_Ginobili = [107-90,100-100]
Tony_Parker = [116-90,106-100]
#Team Database
MIA = [Chris_Bosh,Udonis_Haslem,Lebron_James,Dwayne_Wade,Mario_Chalmers]
SAS = [Tim_Duncan,Tiago_Splitter,Kawhi_Leonard,Manu_Ginobili,Tony_Parker]
#Engine
def engine():
#calculation:
MIA[0[0]] + SAS[0[1]] + MIA[1[0]] + SAS[1[1]] + MIA[2[0]] + SAS[2[1]] + MIA[3[0]] + SAS[3[1]] + MIA[4[0]] + SAS[4[1]] == MIAs
SAS[0[0]] + MIA[0[1]] + SAS[1[0]] + MIA[1[1]] + SAS[2[0]] + MIA[2[1]] + SAS[3[0]] + MIA[3[1]] + SAS[4[0]] + MIA[4[1]] == SASs
print ("Miami", MIAs," ", "San Antonio", SASs)
engine()
这是错误:
Traceback (most recent call last):
File "C:\Users\Kevin Lewis\Desktop\Kevin\Documents\Python\NBA Sim Engine.py", line 27, in <module>
engine()
File "C:\Users\Kevin Lewis\Desktop\Kevin\Documents\Python\NBA Sim Engine.py", line 24, in engine
MIA[0[0]] + SAS[0[1]] + MIA[1[0]] + SAS[1[1]] + MIA[2[0]] + SAS[2[1]] + MIA[3[0]] + SAS[3[1]] + MIA[4[0]] + SAS[4[1]] == MIAs
TypeError: 'int' object is not subscriptable