<filename>ch13ex4_maxrec.py
# ch13ex4_maxrec
"""The max_rec function and its tests."""

def max_rec(lst):
    """Return the largest number in lst."""
    if len(lst) == 1:
        return lst[0]
    m = max_rec(lst[1:])
    if lst[0] > m:
        return lst[0]
    else:
        return m

def max_rec_tests():
    lst = [9, 0, -1, 14, -4, 7, 3]
    assert max_rec(lst) == 14

    lst = [0, 3.14, 9.99, 0, 9.98, 9.99, 3.14]
    assert max_rec(lst) == 9.99

    lst = [10, 2, 8, 0, 3]
    assert max_rec(lst) == 10

    print("All tests passed!")

<filename>ch13ex4_maxrec.py
# ch13ex4_maxrec
"""The max_rec function and its tests."""

def max_rec(lst):
    """Return the largest number in lst."""
    if len(lst) == 1:
        return lst[0]
    m = max_rec(lst[1:])
    if lst[0] > m:
        return lst[0]
    else:
        return m

def max_rec_tests():
    lst = [9, 0, -1, 14, -4, 7, 3]
    assert max_rec(lst) == 14

    lst = [0, 3.14, 9.99, 0, 9.98, 9.99, 3.14]
    assert max_rec(lst) == 9.99

    lst = [10, 2, 8, 0, 3]
    assert max_rec(lst) == 10

    print("All tests passed!")

# ch13ex4_maxrec The max_rec function and its tests. Return the largest number in lst.