Answers for "O(1) for reverse a string python"

2

python reverse a string

#linear

def reverse(s): 
  str = "" 
  for i in s: 
    str = i + str
  return str

#splicing
'hello world'[::-1]
Posted by: Guest on December-09-2020

Code answers related to "O(1) for reverse a string python"

Python Answers by Framework

Browse Popular Code Answers by Language