Python Identifiers

  • It helps us in differentiating one entity from another.
  • The name given to entities like class, function, variables etc is known as identifiers.

Below Are Some Rules For Writing Identifiers:

  • An identifier can be a combination of letters in lowercase(a to z) or uppercase(A to Z) or digits(0 to 9) or an underscore(_).
  • An identifier cannot start with a digit(0 to 9).
  • Keywords cannot be used as identifiers.
  • We cannot use special symbols like: @, #, %, /, & etc in identifiers.

Example

dummyVar = 10
Output
10

Example

As global is a keyword, we cannot use it as identifiers.

global = 1
Output
SyntaxError: invalid syntax

Example

Variable names cannot start with digits.

203_dummyVar = 23
Output
SyntaxError: invalid token

Leave a comment