import re


def extract_code(text):
    """ Extracts the python code from the message

    Return value: (success, code)
        success: True if the code was found, False otherwise
        code: the code if success is True, None otherwise
    """

    regex = r"(?s)```(python)?(\n)?(.*?)```"
    match = re.search(regex, text)
    if match:
        return (True, match.group(3))
    else:
        return (False, None)