Advertisement
Antypas

Function reverse string

Apr 10th, 2020
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.38 KB | None | 0 0
  1. #Create a function that accepts a string and returns the same string reversed.
  2. def reverseString(givenString):
  3.     backString = ""
  4.     for index in range(len(givenString)):
  5.         backString = backString + givenString[-1-index]
  6.    
  7.     return backString
  8.  
  9. print("abcde" + "  ->  " + reverseString("abcde"))
  10. print("Is This Working?" + "  ->  " + reverseString("Is This Working?"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement