SHARE
TWEET

create teams

a guest May 21st, 2019 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from random import choice
  2.  
  3. teams = [[],[],[],[]]
  4. team_names = ['Tigers','Nicks','Winners','Mets']
  5. players = ['Harry', 'Hermione', 'Neville', 'Ginny','Joe','Mark','John','Leo']
  6.  
  7. #create the 4 teams
  8. def create_teams(players,teams):
  9.     #count the 4 teams to split players even
  10.     team_count=0
  11.     #cycle performed while players list has players
  12.     while len(players) > 0:
  13.         player_picked = choice(players)
  14.         teams[team_count].append(player_picked)
  15.         players.remove(player_picked)
  16.         if team_count ==3:
  17.             team_count=0
  18.         else:
  19.             team_count=team_count+1
  20. #print all teams
  21. def print_teams(team_names,teams):
  22.     counter=0
  23.     while counter < 4:
  24.         print(str(team_names[counter]) + " team has the following players: " + str(teams[counter]))
  25.         counter = counter+1
  26.    
  27. #create teams with players
  28. create_teams(players,teams)
  29. print_teams(team_names,teams)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top