Variables
Use a variable to store some value in the program's temporary memory. Declare a variable using a name and assign its value by using a single equal sign (=
) followed by the value. Any object can be stored in a variable:
If you try to reference a variable that has not yet been defined, you will see an error like NameError: name 'my_var' is not defined
.
Don't be surprised if a variable's value changes. It is common to overwrite a variable's value by re-assigning it or manipulating it in some way:
Last updated