Sinisterly

Full Version: [Python] Pig Latin Translator
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hey guys,

I'm pretty new to Python so I wanted to share my very first creation!

Code:
pyg = 'ay'
word = original.lower()
first = original[0]
new_word = original + pyg
original = raw_input('Enter a word:')

if len(original) > 0 and original.isalpha():
    if first == 'a' or first == 'e' or first == 'i' or first == 'o'     or first == 'u':
        print 'Translated: ' + new_word
    else:
        new_word = original[1:] + original[0] + pyg
        print new_word
else:
    print 'You didn\'t type anything!!'

I'd love to hear any feedback!!!

Thanks,
Sparks
Looks pretty cool. If I new pig latin I would use it. xD

AND FINALLY. A thread in Python I did NOT make. It was getting a little lonely : P
(02-02-2014, 04:19 PM)Duubz Wrote: [ -> ]Looks pretty cool. If I new pig latin I would use it. xD

AND FINALLY. A thread in Python I did NOT make. It was getting a little lonely : P

Study the code and you'll get it! Thanks for the feedback.

Lol, I'll be joining you.
Me thinks this is pretty cool. Nice job Smile
Isn't this a CodeAcademy level?
(02-02-2014, 05:01 PM)Adorapuff Wrote: [ -> ]Isn't this a CodeAcademy level?

Yup ^-^
Ah, the good ol' pig latin translator exercise.
(02-02-2014, 03:38 PM)Sparks Wrote: [ -> ]Hey guys,

I'm pretty new to Python so I wanted to share my very first creation!

Code:
pyg = 'ay'
word = original.lower()
first = original[0]
new_word = original + pyg
original = raw_input('Enter a word:')

if len(original) > 0 and original.isalpha():
    if first == 'a' or first == 'e' or first == 'i' or first == 'o'     or first == 'u':
        print 'Translated: ' + new_word
    else:
        new_word = original[1:] + original[0] + pyg
        print new_word
else:
    print 'You didn\'t type anything!!'

I'd love to hear any feedback!!!

Thanks,
Sparks


This didn't exactly work for me and it's probably my Python version so I did some fixes specified for 3 and onward when they make newer versions.

Code:
#Probs to Sparks for creating original#

original = input("Enter a word: ")
pyg = 'ay'
word = original.lower()
first = original[0]
new_word = original + pyg

if len(original) > 0 and original.isalpha():
    if first == 'a' or first == 'e' or first == 'i' or first == 'o'     or first == 'u':
        print("Translated: " + new_word)
    else:
        new_word = original[1:] + original[0] + pyg
        print(new_word)
else:
    print("You didn't type anything!!'")
(02-03-2014, 05:36 AM)Duubz Wrote: [ -> ]This didn't exactly work for me and it's probably my Python version so I did some fixes specified for 3 and onward when they make newer versions.

Code:
#Probs to Sparks for creating original#

original = input("Enter a word: ")
pyg = 'ay'
word = original.lower()
first = original[0]
new_word = original + pyg

if len(original) > 0 and original.isalpha():
    if first == 'a' or first == 'e' or first == 'i' or first == 'o'     or first == 'u':
        print("Translated: " + new_word)
    else:
        new_word = original[1:] + original[0] + pyg
        print(new_word)
else:
    print("You didn't type anything!!'")

Thanks for that! I see... I thought that bug that I had was to do with the program I was using... Thanks!
Nice work Sparks, but if you're going to post code, you should comment out your code to help others who want to learn.
Pages: 1 2