Skip to content

Instantly share code, notes, and snippets.

@joan0fsnark
Created September 6, 2021 19:55
Show Gist options
  • Save joan0fsnark/cc8b62d68d58b5044ec15cf7ae33d297 to your computer and use it in GitHub Desktop.
Save joan0fsnark/cc8b62d68d58b5044ec15cf7ae33d297 to your computer and use it in GitHub Desktop.
Reverses given string
# 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