Advertisement
compdude5

Pig Latin

Jun 3rd, 2014
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.36 KB | None | 0 0
  1. # Purposely obfuscated ("concise", "efficient")
  2. v = list("aeiou")
  3. def pig(w):
  4.     if not w.isalpha(): return w
  5.     w = w.lower()
  6.     if w[0] in v: return w+"way"
  7.     for i, c in enumerate(w):
  8.         if c in v: return w[i:]+w[:i]+"ay"
  9.     return w+"ay"
  10. def pigs(ws):
  11.     return " ".join([pig(w) for w in ws.split()])
  12.  
  13. print(pigs("print statements are fun"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement