Testing--Code Working but not PigLatin


#1



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
else:
    print 'empty'


#2

Here:

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

So,

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

Let me know if this resolves.


#3

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?


#4

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!


#5

Thanks! That solved it!!


#6

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