10.Ending Up



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

Im stuck what do i do?
please help


This line should be part ofif-block.

We can't put anything between if and else block.

if condition:

It will throw an error.


As mentioned in instruction we have to re-assign that value (slice of new_word) to new_word.
Then print new_word


@greentreemee I'm still confused to be honest , but thanks for replaying


Hello @alexblaz69 ,
Can you tell what part of code is not clear to you? I will explain!


I think the problem is HOW do you set new_word to the slice.
When you set it as:
new_word = [1:len(new_word)]

it returns an error message with bad syntax....
I am a noob. This is also my question. Thanks!


As we can see the code (above one), There is no such line as you mentioned.
new_word = [1:len(new_word)]

There're two problems in that code.
We have to introduce a line that will set slice of new_word to itself again.
Then fixing indentation and printing the new_word

and why this new_word = [1:len(new_word)] is wrong?
Cus we have not defined what (object) we're slicing from!

Here we just gave 'slice interval' but left the object we're slicing from.

for ex ..

x = [1,2,3,4,5]

y = x[2:4]

You can see slice range is [2:4] but it also important to mention what we are slicing from. (that is x here)


Thanks for that explanation. I had also failed to mention what object i was slicing from.


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