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 с символами в обратном порядке. Срез (slice) s[::-1] делает это за один шаг.
Click Run to see the output here. · Нажмите Запустить, чтобы увидеть результат здесь.