import re


def find_year(text):
    """
    Extract year from 1940 till 2040.

    Parameters
    ----------
        text: str
            Text selected to apply transformation

    Examples:
    ---------
    ```python
    sentence="India got independence on 1947."
    find_year(sentence)
        >>> ['1947']
    ```
    """
    line = re.findall(r"\b(19[40][0-9]|20[0-1][0-9]|2040)\b", text)
    return line