Okay, so today I wanted to mess around with creating a simple data structure for a volleyball game. Nothing fancy, just something to keep track of players and maybe their positions. Here’s how it went:

First Steps: Player Names
I started by, well, starting! I needed a way to store player names. The most straightforward thing seemed to be a simple list. So, I created a list called players
.
Then I started to fill data. I added six names, just making them up as I went:
- “Alice”
- “Bob”
- “Charlie”
- “David”
- “Emily”
- “Frank”
Adding Positions
Just names wasn’t enough, though. I wanted to know where each player was on the court. So I thought, okay, let’s add positions. I decided to use another list for this, called positions
.
I then filled it with some common volleyball positions, making sure they lined up with my player list:
- “Setter”
- “Outside Hitter”
- “Middle Blocker”
- “Opposite Hitter”
- “Libero”
- “Defensive Specialist”
Putting It Together (Kind Of)
Now I had two lists, but they weren’t really connected. I mean, I knew Alice was the Setter because they were both first in their lists, but the computer didn’t. I thought how can i combined them. And the answer is, it’s very simple. I can use players’ name and positions’ name together!
Print result
I use a very simple way to print and show the final result, i just use a basic “for” loop to print each player with positions, and use an index to represent them:

Finally, i got the output, and the final result show to me, it is very good.