© Sanjib Sinha 2017

Sanjib Sinha, Beginning Ethical Hacking with Python, 10.1007/978-1-4842-2541-7_13

13. Exceptions, Catching Errors

Sanjib Sinha

(1)Howrah, West Bengal, India

I hope you have already written a lot of codes. If you had really done that, you would have encountered one or two errors. There are two distinguishable kinds of errors. The first is “SyntaxError ”. It means, you have error in your syntax. Consider this code:

<code>>>> for i in range(10) print(i)              SyntaxError: invalid syntax              </code>

As you see, I forgot to use “:” in for loop. It is a syntax error.

Another error is “Exceptions ”. It means you write a code perfectly. There are no syntactical errors. But you forget to define a variable. Let us consider these lines of code:

<code> ...

Get Beginning Ethical Hacking with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.