Identifiers are the names that are given to the various program elements such as functions, class, variables, list, tuple etc.
They are defined to give a unique name to an entity to identify it during the run time of the program.
There are some rules for making an identifier in python -
- The first character of an identifier must be an alphabet or underscore.For example -
Three of them are valid identifiers in python.
- The identifiers are not allowed to declare a variable name starts with the digit. For example :-
The above declaration will raise a syntax error.
- It must not be a reserved word of python language. For example -
In this case pass is a keyword of python language so this is invalid declaration.
- The identifier name must avoid special symbols other than underscore and white spaces. For example -
The given identifier is invalidand it will raise an error.
- Python identifiers are case-sensitive that means lowercase and uppercase both are different. For example -
Here, i and I both are different and are stored in different memory locations.