CBSE Class 12 Computer Science
Question 23 of 30
Exception Handling — Question 9
Back to all questions| IOError | IndexError |
|---|---|
| This error is raised if the file requested cannot be opened, or failure of I/O operation. | This error is raised when an index is not found in a sequence, i.e., out of range or out of bounds. |
| Examples of situations that can raise an IOError include: Opening a non-existent file for reading or writing, trying to read from a file that has been closed. | Examples of situations that can raise an IndexError include: Accessing an index that is beyond the length of a list or tuple, trying to access a character in a string at an index that is outside the valid range of indices, using a negative index that is too large for the sequence. |