Identifiers in Python

  • Identifiers can be a combination of letters in lowercase (a to z) or uppercase (A to Z) or digits (0 to 9) or an underscore (_).
  • Names like myClass, var_1 and print_this_to_screen, all are valid example.
  • An identifier cannot start with a digit. 1variable is invalid, but variable 1 is perfectly fine.
  • Identifier can be of any length.

Valid Identifiers

val = 5 name = "ashish" id ="2016_0801"

Invalid Identifier

def = 1 #We cannot use the reserve word as indentifier ax@ = 0 We cannot use special symbols like !, @, #, $, % etc. in identifier.