What is wrong with this code?


#1

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:]
    
    print original

else:
    print 'empty'

#2

When you test your code are the results you get correct?


#3

in your case
new_word = python + p + ay i.e pythonpay and you are printing the original word instead of the new word.
just check out the below code
new_word= word[1:] + first + pyg
print new_word


#4

Please be sure to explain your code snippet.


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.