-
Notifications
You must be signed in to change notification settings - Fork 0
/
teamsChooser.py
108 lines (84 loc) · 2.34 KB
/
teamsChooser.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/usr/bin/pytxhon
from numpy import*
from random import choice
teams = []
players = []
file = open('players.txt', 'r')
players = file.read().splitlines()
print(players)
file = open('teams.txt', 'r')
teams = file.read().splitlines()
print(teams)
#1 print some players
print('1', players[0])
print(players[1])
#2 print teams
print(2, teams)
#3 print random player
print(3, choice(players))
#4 delete random player
randomPlayer = choice(players)
print(4, randomPlayer)
players.remove(randomPlayer)
print(players)
#5 add players print one of them then the new list
newPlayers = ['Tarek', 'Dodier', 'Jaimie']
players.extend(newPlayers)
print(5, choice(newPlayers))
print(players)
#declare empty team lists
teamOne = []
teamTwo = []
teamThree = []
#6 choose a random name for each list
nameTeamOne = choice(teams)
print(6, nameTeamOne)
teams.remove(nameTeamOne)
print(teams)
nameTeamTwo = choice(teams)
teams.remove(nameTeamTwo)
nameTeamThree = choice(teams)
print('teamOne', nameTeamOne)
print('teamTwo', nameTeamTwo)
print('teamThree', nameTeamThree)
#7 choose a random player for each team
while len(players) > 0:
playerOne = choice(players)
print('teamOneSelection : ', playerOne)
teamOne.append(playerOne)
print(nameTeamOne, teamOne)
players.remove(playerOne)
playerTwo = choice(players)
print('teamTwoSelection: ', playerTwo)
teamTwo.append(playerTwo)
print(nameTeamTwo, teamTwo)
players.remove(playerTwo)
playerThree = choice(players)
print('teamThreeSelection : ', playerThree)
teamThree.append(playerThree)
print(nameTeamThree, teamThree)
players.remove(playerThree)
if players == []:
break
print(7, teamOne)
#8 print team names and team players
print('teamOne', nameTeamOne, teamOne)
print('teamTwo', nameTeamTwo, teamTwo)
print('teamThree', nameTeamThree, teamThree)
#9 create a file from a team list
with open('teamOne.txt', 'w') as f:
for item in teamThree:
f.write("%s\n" % item)
#10 choose two random teams for the competition and print in file
competition = []
firstTeamSelected = choice(teams)
competition.append(firstTeamSelected)
teams.remove(firstTeamSelected)
secondTeamSelected = choice(teams)
competition.append(secondTeamSelected)
with open('competition.txt', 'w') as f:
for item in competition:
f.write("%s\n" % item)
break
print(10,'Competiting teams :')
print(competition)