Naming Rules

Code Examples

Example 1

Valid Variable Names: āœ… Starts with a letter. āœ… Contains only letters and numbers. āœ… No spaces or special characters. āœ… Uses an underscore _ instead of a space. āœ… Start with an underscore. āœ… Descriptive and clear purpose.

age = 25
number1 = 10
user_name = "Alice"
_score = 100

Example 2

Invalid Variable Names: āŒ Cannot start with a number. āŒ Hyphens are not allowed. āŒ Spaces are not allowed. āŒ Special characters like @, !, $, % are not allowed. āŒ Reserved keyword in Python have special meaning and cannot be used as variable names.

1number = 10
user-name = "Bob"
full name = "Charlie"
@email = "john@gmail.com"
class = "Math"