-1
我一直在做一个记分员,我不知道如何分配玩家的变量数量为0.例如,如果有3名玩家,那么我需要分配3个不同的变量值这可能吗?如果是这样,怎么样?如果不是,我还能怎么做?Python记分
while True:
try:
numPlayers = int(input("How many people are playing?"))
if numPlayers == 0 or numPlayers == 1 or numPlayers > 23:
print("You cannot play with less than 2 people or more than 23
people.")
else:
break
except ValueError:
print("Please enter an integer value.")
for numTimes in range(0, numPlayers):
#what should i do?
是什么阻止你使用了'list'? – RottenCandy
使用'list'存储所有玩家的分数,例如:'scores = [0] * numPlayers'。然后'分数[0]'将成为第一名球员的得分,'得分[1]'第二名球员的得分...... – CristiFati
谢谢!我会看看我是否可以使用列表 –