I have a list of lists:
playoffTeamList = [[adSeed1, adSeed4], [adSeed2, adSeed3],
[mdSeed1, mdSeed4], (mdSeed2, mdSeed3],
[cdSeed1, cdSeed4], (cdSeed2, cdSeed3],
[pdSeed1, pdSeed4], (pdSeed2, pdSeed3]]
It's list of sports teams that made the play offs (i.e NHL or NBA style playoff format, best of 7 rounds). Each list inside the list are pairs of teams that will face off in the first round. There will be 4 rounds to crown a champion.
What I would like to do is remove the team that loses from each pair and re-arrange the larger list so that the winners are re-bracketed (or relisted) in an iterative process so that the next round looks like:
playoffTeamList = [[adSeed1, adSeed2],
[mdSeed1, mdSeed2],
[cdSeed1, cdSeed2],
[pdSeed1, pdSeed2]]
and next round:
playoffTeamList = [[adSeed1, mdSeed1],
[cdSeed1, pdSeed2]]
and then
playoffTeamList = [[adSeed1, pdSeed2]]
my idea is to just remove the losing team from each list:
for brackets in playoffTeamList:
playoffScoring() # This is an algorithm that plays each game of each best of seven round and returns a winner and/or loser
brackets.remove(brackets[0])
print playoffTeamList
I just can't quite figure out how to re-arrange the larger list so that the winning teams remain and are re-bracketed. Zipping or zip unpacking doesn't seem to get me there. Maybe I'm just missing a method or function that allows me to do this.
Also, I am open to other ideas on how to set up my list so it is more elegant in returning the winners from each round and re-arranging for the next round. Maybe a dictionary? Maybe something else?