Created
September 6, 2021 19:55
-
-
Save joan0fsnark/cc8b62d68d58b5044ec15cf7ae33d297 to your computer and use it in GitHub Desktop.
Reverses given string
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
# Write your reverse_string function here: | |
def reverse_string(word): | |
reverse_word = "" | |
for i in range(len(word)-1, -1, -1): | |
reverse_word += word[i] | |
return reverse_word | |
# Uncomment these function calls to test your function: | |
print(reverse_string("Codecademy")) | |
# should print ymedacedoC | |
print(reverse_string("Hello world!")) | |
# should print !dlrow olleH | |
print(reverse_string("")) | |
# should print |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment