Printing Messages Backwards With Python

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.

ScreenHunter 780 Oct. 31 10.15 Printing Messages Backwards With Python

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)     

Incoming search terms for the article:

Related Posts

Turn A Photo Into A Vector Portrait With Photoshop

Correctly Embed Watermarks In Portrait And Landscape Photos Using Conditional Actions In Photoshop CS6.1

Oregon-Inspired Photoshop Tutorial

Create Google Play’s Tab Navigation Using jQuery And CSS

1 Comment

  1. Grillermo

    11.01.2012

    Easier:
    >>>’mi string’[::-1]
    ‘gnirts im’