What is wrong with my code?


#1

I can't figure out for the life of my why I'm returning "ellohy" instead of "ellohay"

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

#2

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

is your culprit . Specifically pyg [1:len(new_word)] portion which is taking slice of pyg variable (defined as 'ay') from the 'y' or pyg[1] to the end of new_word.
Try new_word = word+first+pyg then on the next line
new_word = new_word[1:len(new_word)]
print new_word