Advertisement
Guest User

Untitled

a guest
Oct 18th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.55 KB | None | 0 0
  1. def word_to_piglatin(word):
  2.     beginning = 0
  3.     uppercase = word[0].isupper()
  4.     word = word.lower()
  5.     for n in range(len(word)):
  6.         if word[n] == "q" and word[n+1] == "u":
  7.             beginning = n+2
  8.             break
  9.         if word[n] in vowels:
  10.             if word[n] == "y" and n == 0:
  11.                 continue
  12.             else:
  13.                 beginning = n
  14.                 break
  15.     piglatin = word[beginning:]+word[0:beginning]+"ay"
  16.     if uppercase:
  17.         piglatin = piglatin[0].upper() + piglatin[1:]
  18.     return piglatin
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement