preforms an actionm based on a user answer

def handle_ans(self, ans_):
        """
        preforms an actionm based on a user answer
        """
        ans = ans_.strip(' ')
        def chack_if_answer_was(valid_keys):
            return any([ans == key or ans.startswith(key + ' ')
                        for key in valid_keys])
        # Custom interactions
        for func, tup in self.actions.items():
            valid_keys = tup[0]
            if chack_if_answer_was(valid_keys):
                func()