Set variable "new_word" equal to the slice as well?


#1


I ain't know why it does accept my code without it can print correct ans? It tell me that i need to set variable "new_word" equal to the slice as well but i did not understand?? Please give me explanation in particular. Thanks much.


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
    print original
    print new_word[1 : len(new_word)]
else:
    print 'empty'


#2

At this point we no longer need to print original, so that line can be removed.

The next line can be assigned to back onto new_word and then print new_word.


#4

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