Today’s featured Python script is a little snippet created by John Santiago Jr. just for fun but of course you might find his code very helpful. This rudimentary script will simply print the message inputted by the user backwards using either string slicing or list() function.
So if you’re feeling like going a little ‘Da Vinci’ on one of your websites, journals, or any other web design projects, then applying this script to it might be a good start. Have fun using it!
#------------------------------------------------------------------------------- # Name: Backwards message # Purpose: Prints message entered by user backwards using string # slicing or list() function # # Author: John Santiago Jr. # # Created: 03/04/2012 #------------------------------------------------------------------------------- def message_lst(): message = input('Enter Message: ') new_message = list(message) new_message.reverse() print('Your message backwards is:') print(''.join(new_message)) def message_str(): message = input('Enter Message: ') new_message = '' while message: new_message += message[-1] message = message[:-1] print('Your message backwards is:') print(new_message)