Guest User


a guest
Dec 3rd, 2019
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Function to print a string backwards
  2. def reverse_string(str):
  3. #slice the string
  4. return str[::-1]
  6. #ask the user to enter a string
  7. str = input("Enter a word or sentence to be reversed; ")
  8. #display the original string and call the reverse string function and
  9. #print the output of the fuction
  10. print("The original word or sentence was " + str + " and reversed is; " + reverse_string(str))
RAW Paste Data