Not Working: Why?


So, I'm on PygLatin: Ending Up. It tells me to perform a function using [1:len(new_word)]. However, when I type 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 [1:len(new_word)]
    print word
    print 'empty'

So what should I do?


Hi @thegoogleguy123,

Currently, your code is taking a slice of pyg.

This line needs to be refined into two lines ...

    new_word = word +first + pyg [1:len(new_word)]

The first of the two lines would be ...

    new_word = word +first + pyg

Then [1:len(new_word)] needs to serve as a slice specification. A slice of new_word should be taken, and assigned to new_word so that, in effect, the first character is removed.

The following statement takes a slice of new_word, beginning at the second character, which has an index of 1, and ending with the final character, inclusively, and assigns the result to new_word ...

    new_word = new_word[1:len(new_word)]

Since the result has been assigned to new_word, this will display it ...

    print new_word


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