10/ 11 "What Am I Doing Wrong?"


I am trying to get just the 2nd to the last letter, but the letter ends up at the beginning and end. What do I do?

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'


Hi btshort, If I understand correctly, you're wondering why your slicing isn't working as you want. You've almost got it:

first = word[0] will give you the first letter of the word, and pyg will add the 'ay', but you probably are trying to get the slice of the word after first, is that correct? If that's right, you should create a variable like this:

middle = word[1:]

That will include the whole word minus the first letter. This is incorrect syntax: new_word = [1:len(new_word)]. You could have written new_word = new_word[1:len(new_word)], but it's unnecessary. If you print a variable new_word that equals middle + first + pyg, I think you'll get the result you want.

Let me know if I misunderstood your question. Good luck!


Thanks so much. big help! :grinning:


hi guys,whats down notmu8uvgia\7yghfyuer