I have this working locally as a stand alone Python program.
When I change it into a function in the online editor, it works until a word makes it to the while loop, then it seems to go into an endless loop on the while statement, and I cannot see what I've done wrong.
Any suggestions, please?
words = text.lower()
words = words.split()#words = list from string 'text'
vowels = ('aeiou')
consonants = ('bcdfghjklmnpqrstvwxyz')
for x in words:
word = str(x)
if word[0] in vowels: #Rule 1
word1 = (word+'ay')
elif (word[:2] == 'xr') or (word[:2] =='yt'): #Rule 1
word1 = (word+'ay')
elif word[0] == 'y':
word1 = (word[1:]+word[0]+'ay')
elif word == 'my':
word1 = (word+'ay')
elif 'qu' in word[:3]:
i = word.rindex('qu')
word1 = word[i+2:]+word[:i+2]+'ay'
else:
#word1 = word
while word[0] in consonants:
word = word[1:]+word[0]
word1 = (word+'ay')
text = text.replace(word, word1)
return text```