Pyglatin Ending Up, help with code please


#1

Hi everyone. So I have a code in Ending Up chapter and I can't understand what's wrong with it? Can you please help? So this is the code:

 pyg = 'ay'

original = raw_input('Enter a word:')

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

And then I press Save and Submit code and need to enter a word. I enter a word, for example - "Python" and that Oops, try again message pops up. It says:
It looks like new_word contains "pythonpay" instead of "ythonpay"!

So I can't understand what is happening. Can someone explain please?


#2

This:

Should all be under the if statement, as by the directions, this code should only be executed if the user's input meets the criteria. Fix that, and you should be good.


#3

AFTER A LOT OF STEARING INTO THE CODE
pyg = 'ay'

original = raw_input('Enter a word:')

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

else:
print 'empty'


#4

Thank you guys :slight_smile: :heart_eyes: Working


#5

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