Last active
September 15, 2019 14:53
-
-
Save ChaitanyaBaweja/57c83952951585757f82d6d4518195fc to your computer and use it in GitHub Desktop.
reversing a string using loops
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_string_loop(original_string): | |
reversed_string = "" | |
for a in original_string: | |
# appending characters in reverse | |
reversed_string = a + reversed_string | |
return reversed_string | |
original_string = "ABCDE" | |
print("Original String : ", original_string) | |
print("Reversed String : ", reverse_string_loop(original_string)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment