Remember that storing information in variables is like putting data into labeled boxes?
For example:
score = 100
Engagement Message
Can you tell me what value is stored in score
?
Now, let's talk about the names we give our variables. Just like you can't label a real box with anything (maybe not symbols or blank spaces), there are rules for naming variables in Python.
Variable names can contain letters (a-z, A-Z), numbers (0-9), and the underscore character (_
).
Engagement Message
Make sense so far?
However, there's a catch with numbers: a variable name cannot start with a number.
So, player1
is a valid name, but 1st_player
is not.
Engagement Message
Do you think we can make a variable named 0_day
?
Another important rule: variable names cannot contain spaces. If you want to represent a multi-word concept, use underscores (_
) instead.
For example, high_score
is good, but high score
is not.
