though I reverse the arrangement of the word, it print out with extra codes. the message shows that "It returns "['!', 'n', 'o', 'h', 't', 'y', 'P']" when it should return "!nohtyP"."please help me out!

because it is a list , you may consider using a string instead : a=" " then get the length of text using len(text) , while the length is >0 a will take text[Text_length - 1] and Text_length will be decremented by 1