Created
September 14, 2019 16:13
-
-
Save njgibbon/d5172e47905cbe72ff24f9f7f1d770f2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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