From c7b0802ffe4f7c4d0e6ba4bfad14a72b528452e2 Mon Sep 17 00:00:00 2001 From: "exercism-solutions-syncer[bot]" <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 14 Nov 2025 20:50:35 +0000 Subject: [PATCH] [Sync Iteration] python/reverse-string/1 --- .../python/reverse-string/1/reverse_string.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 solutions/python/reverse-string/1/reverse_string.py diff --git a/solutions/python/reverse-string/1/reverse_string.py b/solutions/python/reverse-string/1/reverse_string.py new file mode 100644 index 0000000..28a5115 --- /dev/null +++ b/solutions/python/reverse-string/1/reverse_string.py @@ -0,0 +1,14 @@ +def reverse(text): + # Initialize an empty list + reversed_chars = [] + + # 2. Loop backward from the last index to 0 + # Note: 'for' loop is correctly indented once + for i in range(len(text) - 1, -1, -1): + # 3. Append the character using the correct variable name 'text' + # Note: This line is correctly indented twice + reversed_chars.append(text[i]) + + # 4. Join the list of characters back into a single string + # Note: 'return' is correctly indented once + return "".join(reversed_chars)