> For the complete documentation index, see [llms.txt](https://gyansetu-python.gitbook.io/python-programming/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gyansetu-python.gitbook.io/python-programming/error-handling.md).

# Error Handling

Example-1:

```python
def div(a,b):
    try:
        print(a/b)
    except:
        print("error!!")
    
div(100/4)
```

25.0

Example-2:

```python
def div(a,b):
    try:
        print(a/b)
    except:
        print("error!!")
    
div(100/0)
```

error!!

Example-3:

```python
def div(a,b):
    try:
        print(a/b)
    except:
        print("error!!")
        
div(10,"gyansetu")
```

error!!

Example-4:

```python
def div(a,b):
    try:
        print(a/b)
    except ZeroDivisionError:
        print("error!!")
        
div(10,0)
```

error!!

Example-5:

```python
try:
    a = int("hi")
    b = 8
    print(a/b)
except ZeroDivisionError:
    print("error!!")
except ValueError:
    print("this is a value error")
```

this is a value error

Example-6:

```python
try:
    print(10/0)
except Exception as e:
    print(e)
```

division by zero
