Creating variables in Python
Think of a variable as a name attached to a particular object. In Python, variables need not be declared or defined in advance, as is the case in many other programming languages. To create a variable, you just assign it a value and then start using it. Assignment is done with a single equals sign (=
):
Unlike other programming languages, Python has no command for declaring a variable. A variable is created the moment you first assign a value to it.
Example
x = 5
y = "John"
print(x)
print(y