[英]What is the possible solution for this code [Python 3.x]
n_players = int(input('Welcome to the game, please tell me how many players will play: '))
print('Now tell me the names of the ', n_players, ' players')
for i in range(0, n_players):
player_i = input('Enter the name of player',i)
The problem is in the last line where the compiler tell me that exist an error :/ Any ideas? 问题出在编译器告诉我存在错误的最后一行:/有什么想法吗?
You can try this for get player names: 您可以尝试使用此方法获取玩家名称:
player_names = []
for i in range(n_players):
player_i = input('Enter the name of player {}: '.format(i + 1))
player_names.append(player_i)
input
函数不能接收多个参数,您需要插值:
player_list.append(input('Enter the name of player {}'.format(i + 1)))
输入函数将单个字符串作为参数,而不像print可以接受许多项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.