<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def login_failures(user):

    '''
    Query for all accounts which have 3 or more login failures.

    CLI Example:

    .. code-block:: bash

        salt <minion_id> shadow.login_failures ALL
    '''

    cmd = 'lsuser -a unsuccessful_login_count {0}'.format(user)
    cmd += " | grep -E 'unsuccessful_login_count=([3-9]|[0-9][0-9]+)'"
    out = __salt__['cmd.run_all'](cmd, output_loglevel='trace', python_shell=True)

    ret = []

    lines = out['stdout'].splitlines()
    for line in lines:
        ret.append(line.split()[0])

    return ret