Tutorial
Variable Naming Rules in Python
In Python, variable names must follow certain rules to work correctly. Following these rules also makes your code easier to read and understand.
Variable Naming Rules
- Don't start variable name with a number for eg
1name - Start with a letter (a–z, A–Z) or an underscore (
_). - Use only letters, numbers, and underscores. No spaces or special characters.
- Python is case-sensitive:
ageandAgeare different variables. - Choose descriptive names that clearly indicate what the variable stores.
Good Examples ✓
Bad Examples ✗
Using meaningful and readable variable names makes your code easier for you and others to understand.