【发布时间】:2016-10-11 10:22:15
【问题描述】:
我正在尝试将 16 个团队中的两个团队分配给 8 个人中的 8 个人,
这是我所拥有的:
import random
person = ['Ashton', 'Danny', 'Martin', 'Yves', 'Nick', 'Cormac', 'Thierry', 'Ciaran']
team = ['France', 'Switzerland', 'England', 'Slovakia', 'Germany', 'Ukraine', 'Spain', 'Czech Republic', 'Croatia', 'Italy', 'Republic of Ireland', 'Sweden', 'Russia', 'Wales', 'Belgium']
namesTeams = {}
for x in person:
teamName = team[random.randint(0, len(team) -1)]
namesTeams[x] = teamName
team.remove(teamName)
print(namesTeams)
【问题讨论】: