A syntax error occurs when a program does not follow the syntactical rules of the programming language.
Syntax errors are often caused by a spelling mistake, missing characters (such as a closing parenthesis), or badly indented code.
The compiler/interpreter of the program often displays the position of the syntax error. However, in complex projects, this indication is not guaranteed to be correct. For instance, a missing token at line 7 can be compensated by the appearance of the same token at line 10. Some compiler/interpreters continue processing the code and throw a syntax error at the end, because of a missing token.
In some cases, combining multiple syntactically-invalid code pieces can result in syntactically-valid code containing logical errors. Debugging these kinds of errors is often difficult, because the compiler/interpreter usually doesn't recognize such mistakes.