examples of legal variable names and illegal variable names in Python

Legal Names

(i) MyFile

Legal Names

(ii) Val_23

Legal Names

(iii) _Python2

Legal Names More Examples 

my_variable x myVar hello_world _this_is_a_very_long_variable_name

Illegal Names

(i) Py-code Explanation :- Contains special character.

Illegal Names

(ii) is Explanation :- Reserved keyword

Illegal Names More Examples

2x (variable names cannot start with a digit) my-variable (variable names cannot contain hyphens) class (class is a reserved keyword in Python) for (for is a reserved keyword in Python)

Juno spacecraft - Mission to Jupiter - NASA

Visit other story