SHARE
TWEET

reverse

a guest Dec 3rd, 2019 84 Never
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]
  5.  
  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
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top