aboutsummaryrefslogtreecommitdiff
path: root/challenge-031/paulo-custodio/python/ch-1.py
blob: 6d380fde036291aadd3e0ba3bf4ed32ff81fb521 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/python3

# Challenge 031
#
# Task #1
# Create a function to check divide by zero error without checking if the
# denominator is zero.

def divide(num, den):
    try:
        res = num / den
    except ZeroDivisionError:
        return "division by zero trapped"
    else:
        return res

print(divide(5, 2 ))
print(divide(5, 0))