But make sure to set new_word equal to the slice as well


#1
pyg = 'ay'
original = raw_input('Enter a word:')

if len(original) > 0 and original.isalpha():
    word = original.lower()
    first = word[0]
    newword = word + first + pyg
    other = newword[1:len(newword)]
    newword = other
    print newword
else:
    print 'Something went wrong'

What is wrong here!?


#2

I see your problem.
First problem is that you have an extra step, so just delete the 'newword = other' function
Second problem is that you are printing 'newword' instead of 'other'
Third problem is that the error you are getting 'set new_word' which is telling you that you have to use 'new_word' variable so change the 'other = newword[1:len(newword)]' to 'new_word = newword[1:len(newword)]' and change the 'print newword' to 'print new_word'

your fixed code

pyg = 'ay'
original = raw_input('Enter a word:')

if len(original) > 0 and original.isalpha():

word = original.lower()
first = word[0]
newword = word + first + pyg
new_word = newword[1:len(newword)]
print new_word

else:

print 'Something went wrong'

Or you can keep the 'newword = other' function in there and just change the 'other' to '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]
newword = word + first + pyg
new_word = newword[1:len(newword)]
newword = new_word
print newword

else:

print 'Something went wrong'

#3

I keep getting the error message "The value of the original variable looks off, make sure that you entered a word containing only letters.


#4

I have been running into the same problem. I have tried a few different things but keep getting the same error.


#5

Oops, try again. word should contain the .lower()-case version of original.

Why do I get the above error message. The code executes without error:

pyg = 'ay'

original = raw_input('Enter a word:')
word = original[1:]
first = original[0].lower()
print first
print word

if len(original) > 0 and original.isalpha():
new_word = original[1:len(original)].lower() + first +pyg
print new_word
else:
print 'empty'