GOT STUCK in Ending Up


here is my code and I run it while the result is that

Oops, try again. It looks like new_word contains "aaay" instead of "aay"!

so where the problem is? why I got a letter "a" twice?


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
    print new_word
    print 'empty'


seem the problem is not I got an "a" twice

to be more specific

please just see the example

when the input is the word "cake"
the print is "cakecay"

so the first letter appears twice? in the begin and the end of the word?
who can help me?


This line:


does not change the value of new_word :slight_smile:

You have to assign returned value to the variable to make the change:

new_word = new_word[1:]


I got it!


You're very welcome :slight_smile:


thanksssssssssss very much


Thank you for explaining, however I do not understand from the instructions how we had to change the variable " new_word ". I don't think they made this clear enough on how to type this out?


Basically i mean why is the [1:] needed after new_word? i do not understand that portion!


Quote from instructions:

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.

But the default value of the end index is the last index, so we can write [1:len(new_word)] as [1:].


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