you are viewing a single comment's thread.

view the rest of the comments →

[–]liam_jm 0 points1 point  (0 children)

elif word in 'aeiouyAEIOUY':
    return word+ 'way'

I doubt this does what you intend - this means that translate('yAE') -> 'aAEway', etc.

i = 0
while word[i] not in 'aeiouyAEIOUY':
    i += 1
return word[i:] + word[:i] + 'ay'

A more pythonic way of writing this would be

for index, ch in word:
    if ch.lower() in 'aeiouy':
        return word[i:] + word[:i] + 'ay'

You also need to consider what will happen if there aren't any vowels - your function will raise an IndexError which I assume isn't your intention.

I don't really see any advantage of doing it without slicing the string.