Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Function to print a string backwards
- def reverse_string(str):
- #slice the string
- return str[::-1]
- #ask the user to enter a string
- str = input("Enter a word or sentence to be reversed; ")
- #display the original string and call the reverse string function and
- #print the output of the fuction
- print("The original word or sentence was " + str + " and reversed is; " + reverse_string(str))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement