Python Variables

format_list_numberedLesson 3 of 11schedule1 min readview_agenda2 sectionsauto_awesomeAI tutor ready
01

Creating Variables

Python has no command for declaring a variable. A variable is created the moment you first assign a value to it.

Example

x = 5
y = "John"
print(x)
print(y)

Output

5
John
02

Variable Names

A variable name must start with a letter or the underscore character. A variable name cannot start with a number, and can only contain alpha-numeric characters and underscores.