I don't really get what the instructions mean


#1

Hello
Can any of you please help me too
my code looks like this
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 original
else:
print 'empty'
new_word = [1:len(new_word)]
I don't know what the problem is
I don't really get what the instructions mean, too.
Please help me anyone
Thanks


Help on pyglatin 10 "ending up"
#2

Hi ^^

I think you're at PygLatin 10. Ending up. So the instruction says:

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.

Let me try to explain the instructions:

Set new_word equal to the slice (of word) from the 1st index (2nd letter, remember that you count starting from 0) all the way to the end of new_word.

Use [1:len(new_word)] to do this (what 1:len(new_word) does is, to only take the 1st index (2nd letter) of the word you want until the index len(new_word), the number of letters in new_word).

One issue in you program is:

You get an error because the program doesn't know what word you want to use starting from the 2nd letter only:

new_word = new_word[1:len(new_word)]

Now you will actually use the new_word starting from the 2nd letter only :smiley:

You assigned the whole word word + first letter + "ay" to new_word.

For example you type "Nightmare" in your programme. new_word will now be:

"nightmarenay"

so if you now make new_word = new_word[1:len(new_word)], you will have

"ightmareay" as result, which is the result we wanted, right? :grin:

Now you only have to put it into the correct place and your program is done:

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 = new_word[1:len(new_word)]
    print original
    print new_word
else:
    print 'empty'

And you can print out the new word at the end to check your result, that's why I put the print new_word :slightly_smiling:

I hope you understood all of it, if you still have questions feel free to ask me anytime :grin:


#3

I think I get it now
Thank you for your explanation~~:grin: