Answers for "reverse a substrint in python"

28

reverse string in python

'hello world'[::-1]
'dlrow olleh'
Posted by: Guest on December-06-2019
-1

Python reverse a string

# Library
def solution(str):
    return ''.join(reversed(str)) 
  
# DIY with recursion
def solution(str): 
    if len(str) == 0: 
        return str
    else: 
        return solution(str[1:]) + str[0]
Posted by: Guest on March-02-2021

Python Answers by Framework

Browse Popular Code Answers by Language