PygLatin


#1

Hi!. Mi program is working fine, apparently. It traslates any real word to PigLatin without problem. Even though at the end it appears the following message in the script board:

"Oops, try again.
The value for the original variable looks off, make sure that you entered a word containing only letters."

What am I doing wrong?

Thank you!

pyg = "ay"

word = raw_input('Enter a word:')

if len(word) > 0 and word.isalpha():
    word = word.lower()
    first = word[0]
    new_word = word + first + pyg
    length = len(new_word)
    print word
    print new_word[1:length]
else:
    print "empty"


#2

Hi there!
You've got no problem in your code.
Maybe just refresh/restart your browser and try again.
Because I tried out your code and it turned out to be just fine :slight_smile:

Have fun programming!


#3

I'll do that. Thank you very much!


#4

Your Welcome :smile:


#5

pyg = 'ay'

original = raw_input('Enter a word:')

if len(original) > 0 and original.isalpha():
word = (original).lower()
first = word[0]
new_word = word[1:] + first + pyg
print new_word
else:
print 'empty'

Hope this is helpful!

[1:] takes the lower cased word and removes the first letter by selecting the letters from position 1 until the length of the word.
Removed length variable also not needed.
Removed the the first print line as it is not needed for completion of the unit.


#6

Cristal clear Nostalgia and it worked.

Muchas gracias!

Julio G.


#7

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.