[問題]reverse string

看板Python作者 (家齊說我是螞蟻)時間15年前 (2009/11/28 21:10), 編輯推噓1(101)
留言2則, 1人參與, 最新討論串1/1
Please write a function to inverse a string. This function accept a string argument and return the reversed string. For example, reverse (‘apple’) returned ‘elppa’ reverse(‘madam’) returned ‘madam’. Hine: (1) set local variable y = ‘’。 (2) from right to left, read a char from input string and append to the end of y. (3) return y as result reverse 要怎麼寫? 我只是個新手希望大家幫幫我~~謝謝:) -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.44.148.189

11/28 21:39, , 1F
s = 'abc'
11/28 21:39, 1F

11/28 21:39, , 2F
s = s[::-1]
11/28 21:39, 2F
文章代碼(AID): #1B4I5AEE (Python)
文章代碼(AID): #1B4I5AEE (Python)