更新时间:2022-10-24 19:09:37
Turn the integer to a string explicitly then:
players["player_" + str(x)] = Player(input("Name"), input("Starting Wealth"), x)
or use string formatting:
players["player_{}".format(x)] = Player(input("Name"), input("Starting Wealth"), x)
You cannot just concatenate a string (player_
) and an integer (the number between 0
and Player_count
) referenced by x
.