Assigning a name
With `=` you give a value a name so you can use it later.
Used in 129 lessons of the course, from 00.01.
An assignment uses =. The name goes on the left; an expression goes on the right. Python first computes the right side, then makes the name point to that value.
Read it as: "key becomes the result of what is on the right." It is not a math equality. It is an instruction, not a question.
A name is not a box that holds the value. It is a label stuck onto the value. If you later assign another value to the same name, the label moves and the name points to the new one.
You will see this everywhere in the course, from the first lesson: key = term.strip().lower(). Python cleans the text on the right side and leaves the result in key. That way you can use it many times without repeating the work.
name = "Ada"
Reach for it when: you want to keep a result for later or give a value a clear name.
Examples
Common mistake
total = 5 price = total + tax tax = 2 print(price)
Why: Python runs lines in order. When `tax` is used, that name does not exist yet.
How to write it: Assign tax = 2 before the line that uses it.
Common mistake
a = [1, 2] b = a b.append(3) print(a)
Why: `b = a` does not copy the list. It sticks a second label on the same object, so changing one changes the other.
How to write it: If you want an independent copy, use b = a.copy().
