Variable Names
- MUST start with a letter or the underscore character
- CANNOT start with a number
- can only contain alpha-numeric characters and underscores (A-z, 0-9, and_ )
- case-sensitive (age, Age and AGE are three different variables)
- CANNOT be any of the Python Keywords
Legal variable names:
myvar = "John"
my_var = "John"
_my_var = "John"
myVar = "John"
MYVAR = "John"
myvar2 = "John"
Illegal variable names:
2myvar = "John"
my-var = "John"
my var = "John"
Camel Case - each word, except the first, starts with a capital letter:
myVariableName = "John"
Pascal Case - each word starts with a capital letter:
MyVariableName = "John"
Snake Case - each word is separated by an underscore character:
my_variable_name = "John"
Top comments (0)