Variable Names in Python

Photo by Chris Ried on Unsplash

Just like other programming languages, python has its own rules for naming variables.
A valid python variable name must starts with an alphabet or underscore. Allowed characters are letters underscore and numbers(0-9). Also variable names are case sensitive, hence x and X are two different variables in python.
Few valid variable names are:

  • _price
  • weight_in_kg
  • product_3
Few invalid variable names are:
  • 1_account
  • product#2
  • quantity.kg



Comments

Popular posts from this blog