teromakotero

Shuffle List

May 7th, 2019
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.91 KB | None | 0 0
  1. from random import shuffle
  2.  
  3. players = ['Harry', 'Hermione', 'Neville', 'Ginny']
  4. players2 = ['Harry', 'Ginny']
  5. players3 = ['Harry']
  6. players4 = []
  7. players5 = ['A', 'B', 'C', 'D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R']
  8.  
  9. def shuffle_list(team):
  10.     team1 = []
  11.     team2 = []
  12.     shuffle(team)
  13.     if(len(team) == 0):
  14.         print("This is an empty list!")
  15.     for k in range(len(team)):
  16.         if(len(team) > 0):
  17.             team1.append(team.pop())
  18.         if(len(team) > 0):
  19.             team2.append(team.pop())
  20.     print("team1:")
  21.     for i in team1:
  22.         print(i)
  23.     print("")
  24.     print("team2:")
  25.     for j in team2:
  26.         print(j)
  27.     print("")
  28.        
  29.  
  30. print("players")
  31. shuffle_list(players)
  32. print("players2")
  33. shuffle_list(players2)
  34. print("players3")
  35. shuffle_list(players3)
  36. print("players4")
  37. shuffle_list(players4)
  38. print("players5")
  39. shuffle_list(players5)
Advertisement
Add Comment
Please, Sign In to add comment