Python Variable Naming Rules
Learn how to name Python variables clearly: valid names, snake_case, keywords, capitalization, and readable habits.
Sounds useful?
Jump into the interactive version.
No setup. No account. Just Python.
Python Variable Naming Rules
Learn how to name Python variables clearly: valid names, snake_case, keywords, capitalization, and readable habits.
Jump into the interactive version.
No setup. No account. Just 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:
snake_case for normal variablesname and Name are differentBy 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.
Ready to practice this in the browser?
> Play now