Can someone tell me what's wrong with my code???

+1 dwayne lewis · March 10, 2015
pyg = 'ay'

original = raw_input('Enter a word:').lower()

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

else:
    print 'empty'

The code should print out for in case if input is "python" then it should print out "ythonpay"
but that is not the case instead it prints out "pythonpay".

Post a Reply

Replies

Oldest  Newest  Rating
+1 Samuel Oloruntoba · March 10, 2015
Try this

pyg = 'ay'

original = raw_input('Enter a word:').lower()

if len(original) > 0 and original.isalpha():
    word = original.lower()
    first = original[0]
    new_word= word + first + pyg
    print new_word[1:len(new_word)]
else:
    print 'empty'
0 dwayne lewis · March 10, 2015
Last nite while I were trying to solve the problem i tried that  but stilled why its telling me to set new_word equal to the slice as well. anymore suggestions ..
0 Samuel Oloruntoba · March 10, 2015
what python version are you using, if it is version 3 definitely errors would pop up, but for version 2.7 no errors
0 dwayne lewis · March 10, 2015
That's a Codecademy tutorial training am going through and i just stuck right there lol 
every thing seems to be correct but still gets error. i guest it a Semantic error :D:D 
0 dwayne lewis · March 10, 2015
I got the problem all I had to do were to add "new_word=new_word[1:9] " before i called the print function
Thanks anyway for helping " Samuel Oloruntoba" you are awesome help..
  • 1

Python

107,005 followers
About

This section is all about snakes! Just kidding.

Links
Moderators
Bucky Roberts Administrator