Ending Up


Ending up, 'Oops, try again.
It looks like new_word contains "hellohay" instead of "ellohay"!

Oops, try again.
It looks like new_word contains "hellohay" instead of "ellohay"!

Only error message.

It to work

Can i just point out, i have no idea what the ■■■■ is wrong here. Looked at multiple Q&A Threads and i cannot spot anything wrong. Even my friend who finished this course cannot figure it out.

Replace this line with your code. 
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 [1:len(new_word)]
    print new_word
    print 'empty'


This is by no means the best solution, but it'll do:

Try replacing (replace()) the first letter of the word with this (no spaces): ''

Remember to only do it after putting it into a variable.


this line:

new_word [1:len(new_word)]

you take a slice of new_word, but you don't store it anywhere, look at this code:

i = 5
print i + 5
print i
i = i + 5
print i

see how the second line, doesn't store anything. You have the same problem with your slice, store the slice in new_word


here you changed the value but didnt store to new_word
new_word [1:len(new_word)]

so when you print new_word it prints the first value that is

new_word = word + first + pyg


Im sorry but I jus't dont get how any of this work's that you are all suggesting, especially @stetim94's comment.


the point is, in this line:

new_word [1:len(new_word)]

You don't store the slice you take anywhere, store the slice in new_word.


Sorry you have confused me, what is a slice?


An example of a slice would be this: [1:len(new_word)]. This "slices" the word by slicing(removing) out the first letter.


So what did i do wrong, and how would i go about's fixing this? I tend to find if you actually show me the correct coding i would understand it better.


You're not slicing correctly and you're not storing it (to a variable).
Since the slice also deals with an iterable (strings, list, arrays etc.), you can treat your string like a list. idk if you learned anything about lists and indexes, but the syntax would be list[index]. Which your new_word will have to be similar in that regard: new_word[1:len(new_word)]

And then, as @stetim94 said, you need to store that slice. As in you need to assign a variable to that slice (in this case, new_word). Or else, your print new_word will not show that slice.


I'm sorry but i just don't know what to do here.


Ok so you need to set new_word [1:len(new_word)] equal to new_word and then print new_word[1:len(new_word)]

new_word = new_word[1:len(new_word)]
    print new_word[1:len(new_word)]


Thanks you!

Although im still not sure on how that works.


you either update the new_word variable with a slice of new_word (updating of variables shouldn't be new) or you print the slice directly


https://discuss.codecademy.com/t/10-ending-up-how-to-slice-help/55181 this may not be the perfect example (and the other moderators have done a good job explaining it but I understand it can be confusing) This forum post was me struggling with this exact same lesson and I think it would be profitable to read over if your still confused. It helped me so hopefully it helps you :smiley:


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