I am trying to create a function in Python which allows me to know if a string contains a letter "y" which appears in the beginning of a word and before a consonant. For example, the sentence "The word yes is correct but the word yntelligent is incorrect" contains the "y" of the word "yncorrect", so the function has to return True. In addition, it has to return true if the "y" is in capital letters and verifies those same conditions.

I have done it in the following way and it appears as if the program works but I was asked to use the method for strings in Python find and I havent't been able to include it. Any hint about how to do it using the method find? Thank you very much.

```
def function(string):
    resultado=False
    consonants1="bcdfghjklmnñpqrstvwxyz"
    consonants2="BCDFGHJKLMNÑPQRSTVWXYZ"
    for i in range(0,len(string)):
        if string[i]=="y" and string[i-1]==" " and string[i+1] in consonants1:
            resultado=True
            break
        if string[i]=="Y" and string[i-1]==" " and string[i+1] in consonants2:
            resultado=True
            break
    return resultado

print(function("The word yes is correct but the word yntelligent is incorrect"))

```