We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Variables

Variables store data as our program runs. Up 'til now we've been printing data by passing it straight into print(), but now we'll often save data in variables so we can reuse it and change it before printing it.

A "variable" is just a name that we give to a value:

my_height = 72

Here, we've created a my_height variable and we've set it to 72. The name goes on the left of the =, and the value goes on the right.

We could also create a my_name variable and set it to the string "Lane":

my_name = "Lane"

While variables can be named anything (well, almost anything. You can't have spaces in them), it's best to use descriptive names so you can remember why you created it in the first place!

Using Variables

Once you have a variable, you can access its value by using its name. For example, this prints 72:

print(my_height)

And this prints Lane:

print(my_name)

Assignment

We need to keep track of our hero's health!

Replace the # ? on the first line with a new variable named player_health, set to 1000.

Don't change anything else.