forked from palindrome1311/Hacktoberfest2019
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPig_latin_python
33 lines (33 loc) · 917 Bytes
/
Pig_latin_python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""
Write a program that translates the user input (an English word) to Pig Latin.
"""
text = str(input("Enter a word or phrase to be pig-latin-ified"))
#text = "blind eggs"
def pig_it(text):
print ('pigging \n')
break_at_space = text.split(" ")
new_phrase = ''
punctuation = ('.', '!', '?')
vowels = ("a", "e", "i", "o", "u", "y")
for word in break_at_space:
# vowel_check = word[0]
# con_cluster_check = word[1]
if word in punctuation:
new_phrase += word
elif word[0] in vowels:
x = word + "yay" + " "
new_phrase += x
elif word[0] not in vowels:
count = 0
new_word = word
while count < len(new_word):
new_word = new_word[1:len(new_word)] + new_word[0]
if new_word[0] not in vowels:
count += 1
elif new_word[0] in vowels:
x = new_word + "ay" + " "
new_phrase += x
count = len(word)
final = new_phrase.strip()
return final
print (pig_it(text))