Alright, so today I’m gonna spill the beans on something I was messing around with – varsity and jv stuff. Sounds kinda sporty, right? Well, not really, unless you consider wrangling with code a sport, which, let’s be honest, it totally is.
So, I started off with this idea kicking around in my head. I wanted to see if I could easily split some data into two groups, kinda like a varsity team and a junior varsity team. You know, the A-team and the B-team. The “Varsity” group would be the top performers, the best of the best. The “JV” group would be everyone else. Makes sense, yeah?
First thing I did was grab my data. I’m not gonna bore you with the details of where it came from, but let’s just say it was a bunch of numbers that represented, uh, player scores, if you wanna stick with the sports analogy. I loaded it into a list. Pretty basic stuff so far.

Next, I needed a way to actually split the data. I figured the easiest way to do this was to sort the data first. So, I ran a quick sort()
on my list. Boom, highest scores at the top, lowest at the bottom.
Okay, now for the fun part. I decided that the top 25% of scores would be “Varsity.” Seemed like a good starting point. So, I calculated how many items that would be. If my list had, say, 100 scores, then 25 items would make up the Varsity team. Simple math. Used len()
to find the size of the list, and then multiplied it by 0.25. Made sure to cast it to an int
, because you can’t have half a player, right?
Then I just used list slicing. varsity = data[:num_varsity]
That grabs the first num_varsity
items from the list and puts them into a new list called varsity
. Easy peasy.
And then to get the JV team, I just did the opposite: jv = data[num_varsity:]
. That grabs everything after the first num_varsity
items.
I printed both lists out to make sure it worked. And, wouldn’t you know it, it did! Varsity had the highest scores, JV had the rest. Success!
But then I started thinking, what if I wanted to make it more flexible? What if I didn’t always want to split it at 25%? So, I wrapped the whole thing up in a function. The function took two arguments: the list of data and the percentage for the Varsity team. Now I can easily change the split whenever I want.
Something like this:
def split_teams(data, varsity_percentage):
*(reverse=True) # Sort in descending order
num_varsity = int(len(data) varsity_percentage)
varsity = data[:num_varsity]
jv = data[num_varsity:]
return varsity, jv
That’s about it. A pretty simple little project, but it was a fun exercise. And who knows, maybe it’ll come in handy someday. Maybe I’ll use it to actually pick sports teams, or maybe I’ll use it to split up tasks at work – the possibilities are endless! The key is to start small, experiment, and don’t be afraid to get your hands dirty with the code. You’ll learn something new every time.