def pick_penalty(table, wtype, bpart, rank):
    """
    Picks the relevant penalty from the
    specified penalty table based on:
        - The weapon type
        - The body part
        - The seriousness of the damage
    """
    try:
        return table[wtype][bpart][rank]

    except KeyError as error:
        return 'key_error', error.args[0]

    except IndexError as error:
        return 'index_error', error.args[0]