Most words in Pig Latin end in “ay.” Use the rules below to translate normal English into Pig Latin.
- If a word starts with a vowel add the word “way” at the end of the word. Example: Awesome = Awesome +way = Awesomeway
- If a word starts with a consonant, (such as dog) or a consonant cluster (such as brush), simply take the consonant/consonant cluster and move it to the end of the word, adding the suffix ‘ay’ to the end of the word.
For example, ‘dog’ in Pig Latin becomes ‘og-day’ (because the leading consonant ‘d’ has been moved to the end of the word, leaving simply ‘og’ at the beginning, and the suffix ‘-ay’ has been appended to the ‘d’).Our other example was the word ‘brush’, which becomes ‘ush-bray’ in Pig Latin, by following the same rule.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | string1=input("Enter a Sentence: ").strip()words=string1.split()l_words=string1.lower().split()pig_latin=[]for word in l_words: if word[0] in 'aeiou': pig_latin.append(word+'way') else: vowel_pos=0 for w in word: if w in 'aeiou': vowel_pos=word.index(w) break else: pass pig_latin.append(word[vowel_pos:]+word[:vowel_pos]+'ay')for i in range (0,len(words)-1): if words[i].istitle(): pig_latin[i]=pig_latin[i].title()print("Pig Latin Version is: "+" ".join(pig_latin).strip()) |
1 2 3 4 5 6 7 8 | Enter a Sentence: Pig Latin is hard to speakPig Latin Version is: Igpay Atinlay isway ardhay otay eakspayEnter a Sentence: I don’t knowPig Latin Version is: Iway on’tday owknayEnter a Sentence: Shriman is a good BoyPig Latin Version is: Imanshray isway away oodgay oybay |

Comments
Post a Comment