Ending Up Error


#1

I am getting error while running this code

Oops, try again. It looks like you printed the correct translation of "sunday", but make sure to set new_word equal to the slice as well.

Please help me to get it right.

my 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 + first + pyg
    slice=new_word
    print slice[1:]
else:
    print 'empty'


Ending up - I am totally lost
#2

In the instructions, they tell you:

Set new_word equal to the slice from the 1st index all the way to the end of new_word. Use [1:len(new_word)] to do this.

So they're asking for this:

new_word = new_word[1:len(new_word)]

#3

Thanks @bosswanted, it worked.
but if I run following code it gives Error as "Oops, try again. It looks like new_word contains "kaykay" instead of "aykay"!" but surprising I am getting the result as 'ykay' , which seems right to me.

Can you please check what is wrong in this 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 + first + pyg
slice = new_word[1:len(new_word)]
#slice=new_word
print slice[1:]
else:
print 'empty'

Result:
Enter a word: Kay
Kay
ykay
None


#4

Replace slice with new_word.

print new_word[0:]

or

print new_word

When you've done everything, part of the code should look like this:

        new_word = word + first + pyg
        new_word = new_word[1:len(new_word)]
        print new_word[0:]
else:
        print 'empty'

#5

This line here instead of creating a new variable how about just using new_word as the variable name. And also instead of passing new_word next to your list slice write the code like this.

new_word = word[1:len(new_word)] + first + pyg

What this syntax does is what you were trying to do with this line

But instead prints the desired result which would be aykay.

So with the method I have shown you. You don't need this line anymore, print slice[1:]