Skip to content · ⁨본문 바로가기⁩

Reverse a string · ⁨문자열 뒤집기⁩

English

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의 간격으로 끝에서 시작해 문자열을 순회합니다. 원하신다면 루프로 결과를 만들기도 합니다.

Log in or create account · ⁨로그인 또는 계정 만들기⁩

IGCSE, A-Level & AP