Write a Python function to reverse given string


Introduction

Write a Python function to reverse given string. I have used python 3.7 compiler for debugging purpose.


techstudy.org

HP 15 Core i3 7th gen Laptop(4GB, 1TB HDD, Windows 10) | Rs. 31,490

  1. def string_reverse(str):
  2.  
  3. rstr = ''
  4. index = len(str)
  5. while index > 0:
  6. rstr += str[ index - 1 ]
  7. index = index - 1
  8. return rstr
  9. print("Reverse string:")
  10. print(string_reverse('ydutshcet'))

Result

python language techstudy.org

     





Related Topics




Popular Posts