我正在努力弄清楚如何完成我在下面概述的内容。
我正在使用有序字典来跟踪每个玩家(键)的分数(值)。该for循环重复的,因为有球员很多次。
我的想法是更新与xfor 循环中索引相同的键的值,但我似乎无法弄清楚如何执行它。任何建议表示赞赏,我完全有可能以错误的方式处理这个问题。
这是我到目前为止:
numberOfPlayers = input("\nEnter number of players : ")
print("The number of players has been set to %s \n" %
(numberOfPlayers))
numberOfPlayersInt = int(numberOfPlayers)
players = collections.OrderedDict()
for index in range(numberOfPlayersInt):
teamName = input('Team/Player %i, enter a team name :' %(index))
players[teamName] = 0
for x in range(numberOfPlayersInt):
print("Player %d, your question :" % (x + 1))
answer = str(input("\nCorrect ? "))
if answer.lower() in ['y', 'yes']:
pass
#some code here that updates the value for this player.
包含 3 个条目 a - c 的字典如下所示:
OrderedDict([('a', 0), ('b', 0), ('c', 0)])
相关分类