<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def set_code(self, idx):
 """ Sets a code to be filtered on for the conversion. Note that this also sets the 'code_last' attribute and configures to ignore the remaining characters of the code. :param idx: The index at which the code _begins_. :returns: True if the code is valid, False otherwise. """


        code = self.format[idx:idx + 3]

        if len(code) < 3 or not code.isdigit():
            return False

        self.codes.append(int(code))
        self.ignore = 2
        self.code_last = True
        return True