<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def replace_ys(self, word):
 """ Replace y or Y with i if preceded by a non-vowel which is not the first letter of the word ."""

        length = len(word)

        if word[length - 1] in 'Yy':
            if length > 2:
                if word[length - 2] not in self.vowels:
                    word = word[:-1] + 'i'

        return word