Login Register






Pig Latin "Translator" filter_list
Author
Message
Pig Latin "Translator" #1
Yes, it's super simple. Yes, even I can make it in under 10 minutes. But hey, it's my first python program! Enjoy!
(Only words with single words, not sentences!)
If you aren't familiar with pig Latin, it works as follows:

Original word: derp
what pig Latin does:
1. ..erp
2. erpd
3. erpday
So:
derp --> erpday


(Made in a lesson from Codeacademy. Awesome site. (you can also use it as an online editor if you're too lazy to set it up))
Code:
suffix = "ay" original = raw_input("Enter a word:") if len(original) > 0 and original.isalpha(): word = original.lower() first = word[0] newword = word[1:] + first + suffix print newword

2nd version (can process sentences) creds to @Snipa
Code:
suffix = "ay" original = input("Enter your text:") text = original.lower().split() for word in text: print(word[1:] + word[0] + suffix)
It's often the outcasts, the iconoclasts ... those who have the least to lose because they
don't have much in the first place, who feel the new currents and ride them the farthest.

Reply

RE: Pig Latin "Translator" #2
simple enough Smile

i modified it a bit, so you can type a sentence


Code:
suffix = "ay" original = input("Enter your text:") text = original.lower().split() for word in text: print(word[1:] + word[0] + suffix)
[Image: fa00a00749.jpg]

Staff will never ever ask you for your personal information.
We know everything about you anyway.

Bonus

Reply

RE: Pig Latin "Translator" #3
@Snipa I probably sound like an idiot but would this even run correctly?
Code:
text = original.lower().split()
Or would it be something like
Code:
text = original.lower.split()
It's often the outcasts, the iconoclasts ... those who have the least to lose because they
don't have much in the first place, who feel the new currents and ride them the farthest.

Reply

RE: Pig Latin "Translator" #4
The code is wrong and so is your concept about pig latin. A pig latin word is constructed in a way that in a word whenever a vowel is encountered then the alphabets before the vowels are concatenated to the end of that word along with "ey". Also whenever a word starts with a vowel then "way" is concatenated to the original string and not ey.

Your code is not versatile and will work only when the second character is a vowel like "hello", "wow", etc.

But your code gives wrong results for word like "Bye", "Cross", "when" etc. etc.

I hope you will correct the errors.
[Image: OilyCostlyEwe.gif]

Reply

RE: Pig Latin "Translator" #5
(06-25-2014, 04:54 AM)[blank] Wrote: @Snipa I probably sound like an idiot but would this even run correctly?
Code:
text = original.lower().split()
Or would it be something like
Code:
text = original.lower.split()

lower() is a function and so it will work perfectly. Its not a constant or globally defined variable and hence .lower.split() is wrong.

Have a look : http://codepad.org/XPZQdb3k
[Image: OilyCostlyEwe.gif]

Reply

RE: Pig Latin "Translator" #6
(06-25-2014, 05:10 AM)Psycho_Coder Wrote: The code is wrong and so is your concept about pig latin. A pig latin word is constructed in a way that in a word whenever a vowel is encountered then the alphabets before the vowels are concatenated to the end of that word along with "ey". Also whenever a word starts with a vowel then "way" is concatenated to the original string and not ey.

Your code is not versatile and will work only when the second character is a vowel like "hello", "wow", etc.

But your code gives wrong results for word like "Bye", "Cross", "when" etc. etc.

I hope you will correct the errors.
Sounds like I really screwed this one up :Yuck:!
I'm just going with what I learned.
If you need to blame someone, blame the guy that made the course :troll:
It's often the outcasts, the iconoclasts ... those who have the least to lose because they
don't have much in the first place, who feel the new currents and ride them the farthest.

Reply

RE: Pig Latin "Translator" #7
Thats upto yourself whether you wanna correct yourself or not, I mentioned where you lacked the concept.
[Image: OilyCostlyEwe.gif]

Reply