DEV Community

roe0478
roe0478

Posted on

Reserved Words and Syntax Errors

Throughout my learning of Python, I will try to provide some nuggets on the rules of the game. There are rules that we must follow to communicate successfully with Python. Today we are going to talk about one of those rules as well as what happens when a rule is broken.

Reserved words -

The Internet states that in a computer language, a reserved word (also known as a reserved identifier) is a word that cannot be used as an identifier, such as the name of a variable, function, or label – it is "reserved from use". This is a syntactic definition, and a reserved word may have no user-defined meaning.

This basically means that you cannot use these words to name or identify something. A few examples of these reserved words are:
False, None, if, class, True, return, while, for, continue

For a full list of reserved words check this link out! [(https://flexiple.com/python/python-reserved-words/)]

Personally, it almost feels like these words are reserved because this IS the actual language Python speaks or their vocabulary system it uses to communicate with us??? Comment below if I’m on to something or not. I could be having a blow my mind moment but not too sure as of this writing. Now let's briefly discuss what happens when python cannot understand what we are asking it to do.

Syntax Errors:

Syntax errors are actually very important in programming. I didn't really understand how significant they are. To have a “watchman” of sorts to have your back and make sure your program will run. Don't...mind if I doo...

Tecnopedia states that a syntax error in computer science is an error in the syntax of a coding or programming language, entered by a programmer. Syntax errors are caught by a software program called a compiler, and the programmer must fix them before the program is compiled and then run.

The compiler seems to have an important job... (side note: doesn't the compiler seem like it should be a TV show?? I mean..."The Compiler”. But say it with a raspy narrator voice. It would be one of those primetime shows on NBC or something.)..moving on.
You can find more on syntax errors here:
[(https://www.techopedia.com/definition/13391/syntax-error)]

One thing I have been learning; to be a successful programmer we need to make sure our mindset about syntax errors is in the right place. That is, syntax errors are our friends. They let us know that something is wrong before we can move on in our code. We will feel like the computer hates us. We will feel like we can't do this, and nothing is working. Take it from me, I made up some curse words. (Trying to get them added to the dictionary as we speak.)

Syntax errors are a way for the computer to tell us that it doesn't understand what we are trying to say. This gives us the opportunity to not only scan, find and fix the problem - We also learn from those errors. Our neuro receptors remember and after time will correct them allowing a freer flowing code session.

Python language is like other programming languages. You can give it a set of instructions if you know how to talk the language. For example:

x = “Python”
print(x)
Enter fullscreen mode Exit fullscreen mode

Speaking in a way that Python can understand, we say hey: take this small piece of computer memory and label it x then store the name "Python" into this small piece of memory labeled x. Lastly, print whatever the value of x is. This will print “Python” to the screen.

However,

return = “Python”
print(return)
Enter fullscreen mode Exit fullscreen mode

This will not print because we are using a reserved word return as a variable. And we will get a syntax error letting us know why it doesn’t understand.

I'm excited to learn more about how we communicate with python speaking its language and how we can use syntax errors to our advantage.

Thank you for reading Everyone!!
See ya next time....

Top comments (0)