Advertisement
Cobble5tone

Pig Latin

Aug 18th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.56 KB | None | 0 0
  1. def pig_latin(word):
  2.     new_words = []
  3.     subject = word.split()  # Creates a list of words. This works for  individual words or sentences.
  4.     for i in subject:  # Iterates through split word
  5.         first_letter = i[0]
  6.  
  7.         if first_letter in 'aeiou':
  8.             pig_word = i + 'ay'
  9.             new_words.append(pig_word)  # Appends pic latin word
  10.  
  11.         else:
  12.             pig_word = i[1:] + first_letter + 'ay'
  13.             new_words.append(pig_word)  
  14.  
  15.     print(' '.join(new_words))  # Prints content of new_words list. This is for printing sentences
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement