-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLatinPigTranslator.py
More file actions
38 lines (28 loc) · 1.13 KB
/
Copy pathLatinPigTranslator.py
File metadata and controls
38 lines (28 loc) · 1.13 KB
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
34
35
36
37
38
#pig latin translator
# take sentence input from user
# convert that into list of words
#loop over words and check the letters
#if word starts with vovel then add 'yay' at the end and if it starts with consonent then travel till first vovel and append that to end and add 'ay
#egg->eggyay glove-oveglay
#jojn the list workds and frame the sentence
userInput=input('Please provide input for translation :').strip().lower()
userInputList=userInput.split()
newWordsList=[]
for word in userInputList:
if word[0] in 'aeiou':
latinWord=word+'yay'
newWordsList.append(latinWord)
else:
letterPosition=0
for letter in word:
if letter not in 'aeiou':
letterPosition=letterPosition+1
else:
break
consonentPart=word[:letterPosition]
vovelPart=word[letterPosition:]
finalWord=vovelPart+consonentPart+'ay'
newWordsList.append(finalWord)
#frame sensentce from list
translated_statement=" ".join(newWordsList)
print(translated_statement)