DEV Community

Cover image for Variables in Python

Variables in Python

aswin2001barath profile image Aswin Barath Updated on ・1 min read

Variables in programming are something like containers storing some specific things.

Variables are a way we store data on the computer.
This is how we create variables in python:

variable_name = data
Enter fullscreen mode Exit fullscreen mode

But, there's a catch here, you cannot have some crazy names as variable names in python.

There are some best practices in python being followed by the python community when it comes to naming your variable names.


  • Variable names can contain letters, numbers, underscore
  • Always start with a lowercase letter or an underscore
  • snake_case Use lowercase letters and underscores for spaces. Alt Text


  • Do not use reserved keywords of python as variable names, coz this is what python will tell you:

    Traceback (most recent call last):
    File "./", line (x), in <module>
  • Do not use special characters like !,@,#,$,%,^,&,* in a variable name, coz you will get the same error message:

    Traceback (most recent call last):
    File "./", line (x), in <module>


Keep in mind that python is case - sensitive, which means the variable like hello and Hello are very different for python.

Discussion (0)

Editor guide