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可以接受许多项。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.