'Generate a response to the user input.
:type str: str
:param str: The string to be mapped
:rtype: str'

def respond(self, str):

    for (pattern, response) in self._pairs:
        match = pattern.match(str)
        if match:
            resp = random.choice(response)
            resp = self._wildcards(resp, match)
            if (resp[(-2):] == '?.'):
                resp = (resp[:(-2)] + '.')
            if (resp[(-2):] == '??'):
                resp = (resp[:(-2)] + '?')
            return resp
