Is there a naming convention


#1

Question

All the variables we’ve made so far have had underscores between the words if they’re more than one word. Is this the standard style that most people use, or is there some naming convention I should follow?

Answer

Two common styles are camelCase and underscore_separated. You simply start with a lowercase word, and any words after the first are capitalized normally. Or, you separate each word with an underscore and leave it all lowercase.

You also cannot start a variable name with a number. Variable names must begin with an _underscore or a letter.

Be descriptive and don’t leave any ambiguity when naming variables. userInput is much more descriptive and unambiguous than x.
There are lots of conventions you can learn more about in the PEP 8 style guide if you’re interested! It’s definitely not something you need to read through, but will greatly benefit you in the long run.


FAQ: Learn Python - Python Syntax - Variables