Python by Swaroop C H - HTML preview
PLEASE NOTE: This is an HTML preview only and some elements such as links or page numbers may be incorrect.
Download the book in PDF, ePub, Kindle for a complete version.
Download the book in PDF, ePub, Kindle for a complete version.
Try..Except
We will try to read input from the user. Press Ctrl-d and see what happens.>>> s = raw_input('Enter something --> ')
Enter something --> Traceback (most recent call last): File "<stdin>", line 1, in ?
EOFError
Python raises an error calledEOFError which basically means it found an end of file when it did not expect to (which is represented by Ctrl-d)
Next, we will see how to handle such errors.
