def word_for_ampm(hour, ampm):
    """Return 'morning', 'afternoon', or 'evening' for the given hour and
    AM/PM setting.
    """
    if ampm == 'am':
        return 'morning'
    if hour < 6:
        return 'afternoon'
    return 'evening'