Getting and storing player information
Our first task is to figure out how we are going to get and store information from those who play our game. There are a few steps we need to take, including asking the player for their name, and then storing the player's name. We will also perform some code in the background to store information about the player that we have not yet asked for. This is a sneaky bit of coding that is quite fun and will let you expand your game if you want to. Let's walk through each step.
Making a players list
The first thing that we will do is make an empty list to store information about each player. We are going to name the list players
, but we are not going to put anything in our list yet. Why not? Well, our players might be different in each game, and they will have different information too, so we need to allow our game to store this information as our players enter it into the computer. Here is what the players
list looks like:
players = []
Now that we have made this...