Ending Up


#1

this is my code but it doesn't work but I do not understand why.


this is my code that I have created

pyg = 'ay'

original = raw_input('Enter a word:')

if len(original) > 0 and original.isalpha():
    print original
    word= original.lower()
    first= word[0]
    new_word= original + [1:len(new_word)] + first + pyg
    print new_word
else:
    print 'empty'
this is the error message that is coming up
  File "python", line 9
    new_word= original + [1:len(new_word)] + first + pyg
                           ^
SyntaxError: invalid syntax


#2

new_word isn't defined at that point.


#3

true

I see what your problem is, '+' is not needed between original and 'slicing', should be:

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

original[1:len(original) should be together - it means cut the block of letters from original variable from letter no. 1 till last letter (length of the string) of the original variable and not new_word as you wrote