summaryrefslogtreecommitdiff
path: root/tests/basics/try_return.py
blob: a24290c4fb7a9aaf397103ed6ddc461e26ad62ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# test use of return with try-except

def f():
    try:
        print(1)
        return
    except:
        print(2)
    print(3)
f()

def f(l, i):
    try:
        return l[i]
    except IndexError:
        print('IndexError')
        return -1

print(f([1], 0))
print(f([], 0))