Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import randint
- def divideToRandomTeams(PlayersArray):
- if type(PlayersArray) != list:
- print("Argument must be a list")
- return False
- playersOrginizedByRandom = []
- i=0
- numToDo = len(PlayersArray)
- while i < numToDo:
- yy = PlayersArray.pop(PlayersArray.index(PlayersArray[randint(0,len(PlayersArray)-1)]))
- playersOrginizedByRandom.append(yy)
- i+=1
- team1 = []
- team2 = []
- for player in playersOrginizedByRandom:
- if(len(team1) < len(playersOrginizedByRandom)/2):
- team1.append(player)
- else:
- team2.append(player)
- return team1,team2
- # to access the function, simply call it with a LIST variable.
- players = ["fishibrilant","ori6151","n0rel","pudim","Karmiking","johneclips","Magnum","phantomderp"]
- team1,team2 = divideToRandomTeams(players)
- print(*team1)
- print(*team2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement