Why name " A-VARIABLE-NAME" is legal name in phythin | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why name " A-VARIABLE-NAME" is legal name in phythin

29th May 2018, 7:21 AM
Rajasee Ghate
2 Answers
+ 3
You aren't supposed to make use of any special characters other than underscore (_). Be sure to keep the following variable rules in mind: •Variable names can contain only letters, numbers, and underscores. They can start with a letter or an underscore, but not with a number. For instance, you can call a variable message_1 but not 1_message. •Spaces are not allowed in variable names, but underscores can be used to separate words in variable names. For example, "greeting_message" works, but "greeting message" will cause errors. •Avoid using Python keywords and function names as variable names; that is, do not use words that Python has reserved for a particular programmatic purpose, such as the word print. •Variable names should be short but descriptive. For example, name is better than n, student_name is better than s_n, and name_length is better than length_of_persons_name.
29th May 2018, 7:30 AM
Rahul George
Rahul George - avatar
+ 1
Thanks
29th May 2018, 9:16 AM
Rajasee Ghate