Variable names in Python can be of any length. Variables names can have alphabets [A-Z][a-z], digits [0-9] and underscores. A variable name starting with a digit is an invalid variable name.
Mridu Bhatnagar: [0:00] We can do colors = { 'red', 'yellow', 'blue', 'green' }. We can have another variable name as rainbow_colors, and then assign this variable name to an object that has rainbow colors in it. Let us do sequentially 'violet', 'indigo', 'blue', 'green', then you have 'yellow', 'orange', and 'red'.
[0:53] A variable name that has underscore in it is also valid. Variable name can be of uppercase as well. I can do AGE = 30. Variable names are case sensitive. When you do age = 30, this would be considered as a new variable.
[1:27] We can also have rainbow_colors_7. That makes it a combination of alphabets, underscore as well as digit. This is also valid in Python. You can have a combination of underscore, digit as well as alphabets in it.
[1:53] Let us see what happens if we keep first letter of a variable name as a digit. Can I have a variable name as 7_rainbow_colors? Let us see if this name is valid or not. This time we got an error. That means variable name cannot start with a digit.
Member comments are a way for members to communicate, interact, and ask questions about a lesson.
The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io
Be on-Topic
Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.
Avoid meta-discussion
Code Problems?
Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context
Details and Context
Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!