Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2d98c5d

Browse files
Merge pull request avinashkranjan#921 from archanagandhi/master
Piglatin_translator scripts
2 parents b159e6e + ae98e91 commit 2d98c5d

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

‎Piglatin_Translator/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Pig Latin Translator
2+
A secret language formed from English by transferring the initial consonant or consonant cluster of each word to the end of the word and adding a vocalic syllable (usually /eɪ/): so pig Latin would be igpay atinlay
3+
4+
## Rules
5+
1. If a word begins with a vowel, just as "yay" to the end. For example, "out" is translated into "outyay".
6+
2. If it begins with a consonant, then we take all consonants before the first vowel and we put them on the end of the word. For example, "which" is translated into "ichwhay".
7+
8+
## How to run?
9+
10+
- Run the script ```python piglatin.py```
11+
- Enter a Sentence you need to translate to pig latin
12+
13+
Example sentence: hello fellas my name is Archana
14+
15+
## Output
16+
![pigoutput](https://user-images.githubusercontent.com/74424757/115106340-dfd7ee00-9f81-11eb-8412-ad344823be1d.PNG)
17+
18+
19+
## Author
20+
[Archana Gandhi](https://github.com/archanagandhi)

‎Piglatin_Translator/piglatin.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
def main():
2+
lst = ['sh', 'gl', 'ch', 'ph', 'tr', 'br', 'fr', 'bl', 'gr', 'st', 'sl', 'cl', 'pl', 'fl']
3+
sentence = input('ENTER THE SENTENCE: ')
4+
sentence = sentence.split()
5+
for k in range(len(sentence)):
6+
i = sentence[k]
7+
if i[0] in ['a', 'e', 'i', 'o', 'u']:
8+
sentence[k] = i+'yay'
9+
elif t(i) in lst:
10+
sentence[k] = i[2:]+i[:2]+'ay'
11+
elif i.isalpha() == False:
12+
sentence[k] = i
13+
else:
14+
sentence[k] = i[1:]+i[0]+'ay'
15+
return ' '.join(sentence)
16+
17+
def t(str):
18+
return str[0]+str[1]
19+
20+
if __name__ == "__main__":
21+
x = main()
22+
print(x)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /