firstTeamPlace = [] # This is for where the team placed, 1st, 2nd, 3rd etc
firstTeamTotal = []# This is where the scores are added to make a final score
m = {
"1": 4,
"2": 3,
"3": 2,
"4": 1,
}
def firstTeamPoints():
firstTeamTotal.append(m[firstTeamPlace])
def tevent1():
print("This is the relay race event")
print("Please enter the where each team placed next to their name (1-4)")
eventaFirstTeam = input(tnames[0])
firstTeamPlace.append(eventaFirstTeam)
eventaSecondTeam = input(tnames[1])
secondTeamPlace.append(eventaSecondTeam)
eventaThirdTeam = input(tnames[2])
thirdTeamPlace.append(eventaThirdTeam)
eventaFourthTeam = input(tnames[3])
fourthTeamPlace.append(eventaFourthTeam)
print(firstTeamTotal)
firstTeamTotal数组没有被添加到它应该被添加的地方。Idk如何使数组被追加。
我是否只需要创建一个数组
2条答案
按热度按时间sirbozc51#
简化您的逻辑:
如果事实证明它更复杂,你可以使用一个Map:
rdlzhqv92#
您可以以更快、更灵活的方式完成您想做的事情:
这样,在两个事件结束后,您的输出为:
end如果您想获得事件编号2的地点列表,您可以使用
teamsPlaces[1]
,即['5', '4', '3', '2', '1']
通过这种方法,您可以对所有事件使用这个简单的函数,而对团队数量和事件数量没有任何限制。