SHARE
TWEET

create teams v2

a guest May 21st, 2019 72 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. team_name_cont = []
  6. players = ['Harry', 'Hermione', 'Neville', 'Ginny','Joe','Mark','John','Leo']
  7.  
  8. #create the 4 teams
  9. def create_teams(players,teams):
  10.     #count the 4 teams to split players even
  11.     team_count=0
  12.     #cycle performed while players list has players
  13.     while len(players) > 0:
  14.         player_picked = choice(players)
  15.         teams[team_count].append(player_picked)
  16.         players.remove(player_picked)
  17.         if team_count ==3:
  18.             team_count=0
  19.         else:
  20.             team_count=team_count+1
  21.     #create teams contraction
  22.     team_count=0
  23.     #cycle performed while players list has players
  24.     while team_count < 4:
  25.         temp=team_names[team_count]
  26.         team_name_cont.append(temp[0:3])
  27.         team_count=team_count+1
  28. #print all teams
  29. def print_teams(team_names,teams):
  30.     counter=0
  31.     while counter < 4:
  32.         print(str(team_names[counter]) + " team (" + str(team_name_cont[counter]) + ") has the following players: " + str(teams[counter]))
  33.         counter = counter+1
  34.    
  35. #create teams with players
  36. create_teams(players,teams)
  37. 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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top