2.03
Completed
Python Variable Naming Rules Python Variable Naming Rules

Learn how to name Python variables clearly: valid names, snake_case, keywords, capitalization, and readable habits.

Python Variable Naming Rules

Sounds useful?

Jump into the interactive version.

No setup. No account. Just Python.

Interactive Python lesson

Variable Naming Rules in Python

Variables are how you keep track of values in Python, so their names matter more than they first seem. This Block teaches the rules for valid Python variable names, then goes one step further: how to choose names that are actually readable for humans too.

You will learn why names can use letters, digits, and underscores, why they cannot start with a digit, why spaces and dashes cause problems, and how capitalization changes meaning in Python. You will also meet Python keywords, avoid names like print, and practice turning vague names like x and thing into clear names like student_name or favorite_color.

What you will learn:

  • Create valid Python variable names
  • Use lowercase snake_case for normal variables
  • Understand why name and Name are different
  • Avoid Python keywords and confusing built-in names
  • Replace vague variable names with names that explain the value
  • Spot common beginner traps like spaces, dashes, and leading digits

By the end, you will be able to write variable names that Python accepts and future-you can understand without squinting at the screen like something cursed just happened.

> Start now 83 cards · about 9 min

Ready to practice this in the browser?

> Play now