10.Ending Up


#1



https://www.codecademy.com/courses/python-beginner-2W5v7/1/4?curriculum_id=4f89dab3d788890003000096


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)]
else:
    print 'empty'

Im stuck what do i do?
please help


#2

This line should be part ofif-block.

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

if condition:
    #somecode  
#somecode
else:
    #somecode

It will throw an error.

EDIT:

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


#3

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


#4

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


#5

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!


#6

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)


#7

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


#8

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