Module 2 · Variables · Lesson 3 of 8
How to create a variable
You create a variable the moment you put something in it, using the assignment operator, =. Write the name, an =, then the value: score = 100. There's no need to announce the type — Python works it out from the value.
score = 100score
=100
100
=isn't “equals” — it means “put the value on the right into the name on the left.”
Read it right-to-left: = takes the value on the right and stores it in the name on the left. That's why 100 = score is an error — the name has to be on the left. And despite the symbol, it does not mean “equals” in the maths sense.
Run it yourselfruns in your browser · Python
main.py
Try changing the values, or adding a variable of your own. Once a box exists, you can use it anywhere you'd use the value itself — which is exactly the next lesson.