Sinisterly
Pig Latin "Translator" - Printable Version

+- Sinisterly (https://sinister.li)
+-- Forum: Coding (https://sinister.li/Forum-Coding)
+--- Forum: Python (https://sinister.li/Forum-Python)
+--- Thread: Pig Latin "Translator" (/Thread-Pig-Latin-Translator)



Pig Latin "Translator" - Inori - 06-24-2014

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)



RE: Pig Latin "Translator" - Snipa - 06-25-2014

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)



RE: Pig Latin "Translator" - Inori - 06-25-2014

@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()



RE: Pig Latin "Translator" - Psycho_Coder - 06-25-2014

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.


RE: Pig Latin "Translator" - Psycho_Coder - 06-25-2014

(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


RE: Pig Latin "Translator" - Inori - 06-25-2014

(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:


RE: Pig Latin "Translator" - Psycho_Coder - 06-25-2014

Thats upto yourself whether you wanna correct yourself or not, I mentioned where you lacked the concept.