Guest User

Untitled

a guest
Oct 19th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. sentence = input("What sentence do you want to translate to Pig Latin? ")
  2. sentence = sentence.split()
  3.  
  4. sentence_pigified = ""
  5.  
  6. clusters = {"bl", "cl", "fl", "gl", "pl", "sl", "br", "cr", "dr", "fr", "gr", "pr", "tr", "sc", "sk", "sm", "sn", "sp", "st", "sw", "tw"}
  7. consonants = {"b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "q", "r", "s", "t", "v", "x", "z", "w", "y"}
  8. vocals = {"a", "e", "i", "o", "u"}
  9.  
  10. for word in list(sentence):
  11. if word[0] in vocals:
  12. sentence_pigified += (word + "ay") + " "
  13.  
  14. if word[:2] in clusters:
  15. sentence_pigified += (word[2:] + word[:2] + "ay") + " "
  16.  
  17. elif word[0] in consonants:
  18. for i in word:
  19. if i in vocals:
  20. sentence_pigified += (word[word.find(i):] + word[:word.find(i)] + "ay") + " "
  21. break
  22.  
  23. print(sentence_pigified)
Add Comment
Please, Sign In to add comment