Skip to content

Instantly share code, notes, and snippets.

@qwertyowmx
Created January 18, 2023 14:55
Show Gist options
  • Save qwertyowmx/5ac252c951eca93b1716e067736d6b8c to your computer and use it in GitHub Desktop.
Save qwertyowmx/5ac252c951eca93b1716e067736d6b8c to your computer and use it in GitHub Desktop.
Python reverse string (slow)
def reverse_str(s: str):
accumulator_str = []
index = len(s)
while index:
index -= 1
accumulator_str.append(s[index])
return ''.join(accumulator_str)
print(reverse_str("abcde"))
print(reverse_str("abcdef"))
print(reverse_str("abcdeaaa"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment