Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import choice
- teams = [[],[],[],[]]
- team_names = ['Tigers','Nicks','Winners','Mets']
- players = ['Harry', 'Hermione', 'Neville', 'Ginny','Joe','Mark','John','Leo']
- #create the 4 teams
- def create_teams(players,teams):
- #count the 4 teams to split players even
- team_count=0
- #cycle performed while players list has players
- while len(players) > 0:
- player_picked = choice(players)
- teams[team_count].append(player_picked)
- players.remove(player_picked)
- if team_count ==3:
- team_count=0
- else:
- team_count=team_count+1
- #print all teams
- def print_teams(team_names,teams):
- counter=0
- while counter < 4:
- print(str(team_names[counter]) + " team has the following players: " + str(teams[counter]))
- counter = counter+1
- #create teams with players
- create_teams(players,teams)
- print_teams(team_names,teams)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement