Reverse a string · 文字列を逆にする
Reverse a string
Return the string with its characters back-to-front: reverse_string("abc") gives "cba".
Python slicing has a neat trick: s[::-1] walks the string with a step of -1, from the end to the start. You can also build the answer with a loop if you prefer.
ストリングを逆順にする
文字の並びを逆にしたストリングを返します: reverse_string("abc") は "cba" を与えます。
Pythonのスライシングには便利な技があります: s[::-1] はストリングを -1 のステップで、末尾から先頭へたどります。必要であればループを使って作成することもできます。
Write reverse_string(s) that returns s with its characters in reverse order. A slice s[::-1] does it in one step. · reverse_string(s) を書いて、s の文字を逆順にしたものを返してください。スライス s[::-1] で1ステップでできます。
Click Run to see the output here. · 実行ボタンをクリックして出力を確認してください。