# Errors and Exceptions

{% embed url="https://www.hackerrank.com/domains/python?filters%5Bsubdomains%5D%5B%5D=errors-exceptions" %}

## Exceptions

<figure><img src="https://3452970062-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhMewGT4PbQ5e1zQPC4Ko%2Fuploads%2FDsJ0XnWwEf2b6CseyxR4%2Fimage.png?alt=media&#x26;token=ec9d19c0-bcac-41c6-af81-eeda9f86d133" alt=""><figcaption></figcaption></figure>

{% code lineNumbers="true" %}
```python
for i in range(int(input())):
    try:
        a, b = map(str, input().strip().split(' '))
        print(int(a) // int(b))
    except ValueError as e:
        print(f"Error Code: {e}")
    except ZeroDivisionError as e:
        print(f"Error Code: {e}")
```
{% endcode %}

***

## Incorrect Regex

<figure><img src="https://3452970062-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhMewGT4PbQ5e1zQPC4Ko%2Fuploads%2FfXv4RFKwV7eQsxuLf514%2Fimage.png?alt=media&#x26;token=ff6564d4-eb51-47d9-be88-0237ef549561" alt=""><figcaption></figcaption></figure>

```python
# Run with pypy3
import re

for _ in range(int(input())):
    regex = input()
    try:
        re.compile(regex)
        print(True)
    except re.error:
        print(False)
```
