Now when it comes to naming your variables,
you can pretty much call it whatever it is you want.
So instead of calling this name,
I could have just called it n and I could have called this l and as long as I'm
consistent.
So if I wanted to get the length of N then I would have to change this as well.
And if I wanted to print out L then I have to change this as well.
But there's a couple of rules that you should probably follow.
And the most important one is to make your code readable. Because if you come
back to this in six months, 12 months,
N and L is not going to have a lot of meaning for you.
So try to make sure that it actually makes sense to you.
And if you want to,
you can actually have multiple words in the name of your variable.
So for example, if you wanted to call this username,
then you would write the word user and then you would separate each of the words
with an underscore. But you can't have a space in between.
This is not valid code and if you try to run it, you'll get a syntax error.
So the name of the variable has to be one single unit and in order to separate
words in Python, we use the underscore.
Now if you want to use numbers in the name of your variable,
you can. So for example, length1,
length2. But they can't be at the beginning of the name of the variables.
You can't say 1length or 3length.
That will generate a syntax error as well. Finally,
there's certain privileged words that we use, for example,
the names of our functions like print and input.
And it's usually good practice to not use them as the names of your variables
because you can see that syntax highlighting gets messed up because it thinks
that is actually input function you're trying to create.
And even though often when you run your app, it might not have any issues,
this is really bad practice because it's very confusing.
So try to make sure that all the names of your variables get highlighted,
like the other variables in the same color. Now,
the final thing to remember is that if you decide to call your variable this
particular name, n-a-m-e, and at a later point you make a typo and you spell it
wrong, so maybe instead of name you said nama,
this is not going to work and when you run your code you'll get what's called a
name error because it says this name is not defined. And the idea is that you
would look at where the error is, line 2, print nama and you'll see,
Oh that's not right. It's meant to be spelled n-a-
m-e. So you'll have to go and fix it in order for your code to work.
Now remember that this is not because Python is doing any sort of spell-checking
for you. It's like, Oh, that's not how you spell name. No. In fact,
if you decided to call this nama and you, later on, used it as name,
there's no problems, there's no issues, no errors,.
As long as it's consistent,
this is the name that's associated with this piece of data. Later on,
when you want to use this piece of data, you use this name to refer to it.
And as long as these two spellings are identical,
then the computer doesn't care at all.
So when you get a name error in your code,
you now know it's probably because you've misspelled or mistyped one of the
variable names somewhere in your code. Now in the next lesson,
I prepared a quiz for you where you'll get to select which variable names are
valid and which ones are not good practice.
Have a go at that over on the next lesson.