Ad
Fundamentals
Strings
Code
Diff
  • def reverse_string(string):
        return string[::-1]
    
    • def reverse_string(string):
    • reversed_list = [string[letter] for letter in range(len(string) - 1, -1, -1)]
    • return "".join(reversed_list)
    • return string[::-1]
Fundamentals
Strings
Code
Diff
  • from collections import deque
    
    def reverse_string(string):
        return string[::-1]
    • from collections import deque
    • def reverse_string(string):
    • reversed_str = deque("")
    • [reversed_str.appendleft(letter) for letter in string]
    • return "".join(reversed_str)
    • return string[::-1]