A variable declaration is quit different than other programming languages.
Python has no command for declaring variable. When you assign any value then it will declared as variable.
a = 1 b = "One" print(a) print(b)
Also, same as other languages, we don’t need to declare variable type in Python. It will changes based on the assigned value.
There are some rules to declare variables in Python:
- Must start with an alphabet or underscore
- Can not start with a number
- Contains only Alpha-Numeric Characters and underscores (A-Z, a-z, 0-9, _)
- Case-Sensitive
For variable assignment, you can assign values to more than one variables in single line.
a, b, c = 1, 2, 3 print(a) 1 print(b) 2 print(c) 3