Skip to content

Instantly share code, notes, and snippets.

@njgibbon
Created September 14, 2019 16:13
Show Gist options
  • Save njgibbon/d5172e47905cbe72ff24f9f7f1d770f2 to your computer and use it in GitHub Desktop.
Save njgibbon/d5172e47905cbe72ff24f9f7f1d770f2 to your computer and use it in GitHub Desktop.
def reverse_2(s: str) -> str:
s_length = len(s)
s_list = list(s)
j = s_length-1
for i in range(s_length-1):
swap_var = s_list[j]
s_list[j] = s_list[i]
s_list[i] = swap_var
j=j-1
if (j<i):
break
return ''.join(s_list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment