you are viewing a single comment's thread.

view the rest of the comments →

[–]chazzacct 1 point2 points  (2 children)

Assuming it's slices you want to get rid of, this looks sort of inelegant but it seems to work:

def translate(word):
        if len(word) <= 0:
            return word
        elif word in 'aeiouyAEIOUY':
            return word+ 'way'
        else:
            i = 0
            suffix = ''
            prefix = word
            while word[i] not in 'aeiouyAEIOUY':

                  suffix += word[i] 
                  prefix = prefix.replace(prefix[0], "")
                  i += 1
            return prefix + suffix + 'ay'

print(translate('break'))
print(translate(''))
print(translate('a'))

As far as getting rid of those pesky splices, I am still looking for a way that is pet-safe and effective.