10/11 is something wrong with my code?


#1

my code keeps returning allanaay for allan and so on. is there a problem?
this is how it looks

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


#2

This does not actually assign the value of new_word to new_word[1:len(new_word)]
To do this, you have to use the assignment operator "="

So your code almost works, but you have to make new_word = new_word[1:len(new_word)] before you print new_word. Like so:

pyg = 'ay'

original = raw_input('Enter a word:')

if len(original) > 0 and original.isalpha():
word = original.lower()
first = word[0] #for hello, this is h
new_word = word + first + pyg #for hello, this is hello+h+ay
new_word = new_word[1:len(new_word)] # for hellohay, this is ellohay
print new_word #for hellohay, this is ellohay
else:
print 'empty'

Or just print new_word[1:len(new_word)] and remove the line before your print statement, like so:
pyg = 'ay'

original = raw_input('Enter a word:')

if len(original) > 0 and original.isalpha():
word = original.lower()
first = word[0] #for hello, this is h
new_word = word + first + pyg #for hello, this is hello+h+ay
print new_word[1:len(new_word)] #for hellohay, this is ellohay
else:
print 'empty'