Alright, so today I’m gonna walk you through how I tackled a little project: simulating a championship league draw. Nothing too fancy, just a bit of fun with some lists and random choices. Let’s dive in!

The Setup: Teams and Pots
First things first, I needed some teams. I just grabbed a bunch of names, you know, the usual suspects. Then, I divided them into “pots” based on their ranking or whatever. I just made it up as I went along, honestly.
teams = ['Real Madrid', 'Liverpool', 'Bayern Munich', 'PSG', 'Man City', 'Chelsea', 'Barcelona', 'Juventus', 'Ajax', 'Dortmund', 'Atletico Madrid', 'Inter Milan', 'Man United', 'Sevilla', 'Benfica', 'Porto']
pot1 = teams[:4]

pot2 = teams[4:8]
pot3 = teams[8:12]
pot4 = teams[12:]
The Core Logic: The Draw Function

Okay, this is where the “magic” happens. I wrote a function to actually perform the draw. The idea is simple: go through each pot, pick a team at random, and assign them to a group. I wanted to make sure teams from the same country couldn’t be in the same group, so I added a check for that.
import random
def draw_groups(pot1, pot2, pot3, pot4):
groups = {

'Group A': [],
'Group B': [],
'Group C': [],
'Group D': []
pots = [pot1, pot2, pot3, pot4]

group_names = list(*())
for pot in pots:
for group_name in group_names:
if len(groups[group_name]) < 4:
while True:

team = *(pot)
country = get_country(team) # I'll explain this later
if not any(get_country(t) == country for t in groups[group_name]):
groups[group_name].append(team)
*(team)

break
return groups
Country Check: Avoiding Same-Country Clashes
This was a bit tricky. I needed a way to figure out which country each team belonged to. I just created a simple dictionary. It’s not perfect, but it did the job for this little exercise.

def get_country(team):
country_map = {
'Real Madrid': 'Spain',
'Barcelona': 'Spain',

'Atletico Madrid': 'Spain',
'Sevilla': 'Spain',
'Liverpool': 'England',
'Man City': 'England',
'Chelsea': 'England',

'Man United': 'England',
'Bayern Munich': 'Germany',
'Dortmund': 'Germany',
'PSG': 'France',
'Juventus': 'Italy',

'Inter Milan': 'Italy',
'Ajax': 'Netherlands',
'Benfica': 'Portugal',
'Porto': 'Portugal'
return country_*(team)

Running the Simulation and Seeing the Results
Once I had the functions ready, I just ran the draw and printed out the groups. Pretty straightforward.
groups = draw_groups(*(), *(), *(), *()) # Use copies to avoid modifying original lists

for group, teams in *():
print(f"{group}: {', '.join(teams)}")
The Output: A Championship League Draw
The output looked something like this:

Group A: Real Madrid, Man City, Ajax, Man United
Group B: Liverpool, Chelsea, Dortmund, Sevilla
Group C: Bayern Munich, Barcelona, Atletico Madrid, Benfica
Group D: PSG, Juventus, Inter Milan, Porto

A Few Gotchas
- Copying Lists: I messed up initially by modifying the original `pot` lists directly. This caused problems when I ran the draw multiple times. Lesson learned: use `.copy()` to create copies of the lists.
- Country Logic: The `get_country` function is super basic. A real implementation would need a proper database or API to get accurate country information.
Wrapping Up
So, that’s how I simulated a championship league draw. It’s a simple project, but it was a fun way to play around with lists, random choices, and some basic logic. Plus, it’s always fun to see what kind of crazy group combinations you can get!