Itertools Combinations or product implementation

  Kiến thức lập trình

Here below is the code snippet. I am trying to return a list of all possible matches which combinations does right however I am looking for a way to return all possible matches as for a double round-robin tournament where each team plays another home and away. Therefore Italy vs England and England vs Italy are two different matches but for combinations it is considered the same. Any work-around? I would also like to assign each match a unique number


# Generate all matchups (home and away)
all_matchups = [
    (team1, team2,match_number(team1,team2,teams)) for team1, team2 in combinations(teams, 2)
]   # Duplicate each matchup to represent home and away games

print(all_matchups)```

LEAVE A COMMENT