<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def valid_hotp( token, secret, last=1, trials=1000, digest_method=hashlib.sha1, token_length=6, ):
 """Check if given token is valid for given secret. Return interval number that was successful, or False if not found. :param token: token being checked :type token: int or str :param secret: secret for which token is checked :type secret: str :param last: last used interval (start checking with next one) :type last: int :param trials: number of intervals to check after 'last' :type trials: int :param digest_method: method of generating digest (hashlib.sha1 by default) :type digest_method: callable :param token_length: length of the token (6 by default) :type token_length: int :return: interval number, or False if check unsuccessful :rtype: int or bool 4 False False """

    if not _is_possible_token(token, token_length=token_length):
        return False
    for i in six.moves.xrange(last + 1, last + trials + 1):
        token_candidate = get_hotp(
            secret=secret,
            intervals_no=i,
            digest_method=digest_method,
            token_length=token_length,
        )
        if token_candidate == int(token):
            return i
    return False