Python: Not able to slice string -
i trying make 1 program using python user has put value equal name or word , cut first letter of word , paste @ end of word , adds 2 more alphabet equal 'py'.
ex- enter value: shashank 'output getting shashankspy' value want 'hashankspy'
the code made this:
pyg = 'ay' original = raw_input('enter word:') if len(original) > 0 , original.isalpha(): print original word = original.lower() first = word[0] new_word = word + first + pyg new_word[1:] else: print 'empty'
i not able real value. please help!
there 1 simple error making , can done as:
new_word = new_word[1:len(new_word)] pyg = 'ay' original = raw_input('enter word:') if len(original) > 0 , original.isalpha(): print original word = original.lower() first = word[0] new_word = word + first + pyg new_word = new_word[1:len(new_word)] else: print 'empty'
Comments
Post a Comment