Skip to content
Justice Tech School

Variable Names

A name must start with a letter or underscore, can contain letters, digits and underscores, and is case sensitive: age and Age are different. A name cannot be a reserved word such as if or class.

The convention is snake_case: lowercase words joined by underscores, for example first_name.

Example
first_name = "Ada"
FirstName = "Grace"
_hidden = 1
age2 = 21
print(first_name, FirstName, _hidden, age2)

Result

Ada Grace 1 21

Exercise

Which style do Python variables normally use?

firstname = "Ada"

Quiz Test

Which is a valid variable name?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.