Testing--Code Working but not PigLatin


Code is behaving fine, no errors are coming up. BUT it doesn't actually do the Piglatin thing. If I take the pyg variable out there is no change.
So I type in "Pollyanna" and enter it.
What comes up is "Pollyanna"

Anyone else have this issue?

pyg = 'ay'

original = raw_input('Enter a word:')

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



You want to get characters from second to last only, and not also concantenate first and pyg variables again.


new_word = new_word[1:len(new_word)] #Gets characters from 2nd to last"

Let me know if this resolves.


Thanks! Unfortunately it's still not working.

Now it's saying
"Oops, try again. It looks like new_word contains "ollyanna" instead of "ollyannapay"! "

Any thoughts?


Look at your code-

You don't need to add first and pyg to word again but you need to slice new_word.

new_word = new_word[1:len(new_word)]

Note that I am slicing new_word not word

Would be enough! I hope it helps!


Thanks! That solved it!!


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