10/11 "string index out of range"


#1

OKAY! So I have been trying to figure this out. I'm pretty new to Python and I need some help with "Ending Up". This is my code so far, please feel free to edit it as you see fit.

pyg = 'ay'

original = raw_input('Dani')

Dani = original.lower()
s = Dani

first = Dani[0] # will print "D"

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

if len(original) > 0 and original.isalpha():
print new_word
else:
print 'empty'


#2

this is what i have for 10/11 - hope it helps - i will comment it for you

pyg = 'ay'

original = raw_input('Enter a word:') #receive a word from the user

if len(original) > 0 and original.isalpha(): #check if length is above 0 and if it's a word not a number
    word = original.lower() #convert to new lower case word
    first = word[0] #take first letter of the new lower case word
    new_word = word + first + pyg #combine with the rest
    new_word = new_word[1:len(new_word)] #cut from the second character to the end of the word
    print new_word
else:
    print 'empty'

#3

Thank you so much! I had to tweak it a tiny bit, but it worked! Where it says "Enter a Word" inside the parentheses in the third line, I had to leave the parentheses empty. So my code looked something like this:

pyg = 'ay'

original = raw_input() #receive a word from the user

if len(original) > 0 and original.isalpha(): #check if length is above 0 and if it's a wo
rd not a number
word = original.lower() #convert to new lower case word
first = original[0] #take first letter if the new lower case word
new_word = word + first + pyg
new_word = new_word[1:len(original)]

print new word

else:
print 'empty'