你好,我对python相当陌生,但我正在尝试找出如何分配循环中已经存在的多个变量(在本例中是名称和ID号)
This is the example的循环,因为我正在制作一个程序,手动将人员放入不同的团队,然后打印当前团队
输入应该是名称和ID号。到目前为止,我已经试过了,但不知道该怎么办。也许把它们放到字典里,然后把它们分配给一个团队
team_size = int(input('What is the team size: '))
for i in range(team_size):
num = num + 1
print(f'Enter students for team {num}:')
temp = input().split(' ')
manual_dict.update({temp[0]: temp[1]})
您可以将拆分结果分配给多个变量:
结果(输出):
更多信息here
相关问题 更多 >
编程相关推荐