def englishtopiglatin(message) piglatin ' string of the pig latin translation for word in message split() separate the non-letters at the start of this word prefixnonletters ' while len(word and not word[ isalpha() prefixnonletters +word[ word word[ : if len(word= piglatin piglatin prefixnonletters continue separate the non-letters at the end of this word suffixnonletters ' while not word[- isalpha() suffixnonletters word[- suffixnonletters word word[:- remember if the word was in uppercase or titlecase wasupper word isupper( wastitle word istitle( word word lower(make the word lowercase for translation separate the consonants at the start of this word prefixconsonants ' while len(word and not word[ in vowels prefixconsonants +word[ word word[ : add the pig latin ending to the word if prefixconsonants !'' word +prefixconsonants 'ay else word +'yay set the word back to uppercase or titlecase if wasupper word word upper( if wastitle word word title( add the non-letters back to the start or end of the word piglatin +prefixnonletters word suffixnonletters return piglatin if __name__ ='__main__' main(pig latin