An identifier is a word used to name things. A variable name is one example of an identifier. Python has strict rules for variable names or identifiers. These are as follows:
- An identifier must contain at least one character.
- The first character of an identifiers must be an alphabetic letter (upper or lower case) or the underscore.
- The remaining characters (if any) may be alphabetic characters (upper or lower case), the underscore, or a digit.
- No other characters (including spaces) are permitted in identifiers.
- A reserved word cannot be used as an identifier.
Examples of valid Python identifiers include:
Python reserves a number of words for special use that could otherwise be used as identifiers. Called reserved words or keywords, these words are special and are used to define the structure of Python programs and statements. None of the reserved words in Table may be used as identifiers. If you try to use it as a variable name then the interpreter will issue an error.
Table below lists all the Python reserved words.
To learn more join our Python course