Return to Snippet

Revision: 56539
at April 14, 2012 12:30 by jdsantiagojr


Updated Code
#-------------------------------------------------------------------------------
# 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)

Revision: 56538
at April 3, 2012 12:12 by jdsantiagojr


Updated Code
#-------------------------------------------------------------------------------
# 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)

    print('Your message backwards is:')
    print(''.join(reversed(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)

Revision: 56537
at April 3, 2012 12:06 by jdsantiagojr


Updated Code
#-------------------------------------------------------------------------------
# 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)

    print('Your message backwards is:')
    print(''.join(reversed(new_message)))

def message_str():
    message = input('Enter Message: ')

    while message:
        new_message += message[-1]
        message = message[:-1]

    print('Your message backwards is:')
    print(new_message)

Revision: 56536
at April 3, 2012 12:05 by jdsantiagojr


Updated Code
#-------------------------------------------------------------------------------
# Name:        Backwards message
# Purpose:     Prints message enterd 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)

    print('Your message backwards is:')
    print(''.join(reversed(new_message)))

def message_str():
    message = input('Enter Message: ')

    while message:
        new_message += message[-1]
        message = message[:-1]

    print('Your message backwards is:')
    print(new_message)

Revision: 56535
at April 3, 2012 12:01 by jdsantiagojr


Updated Code
#-------------------------------------------------------------------------------
# Name:        Backwards message
# Purpose:     Prints message enterd 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)

    print(''.join(reversed(new_message)))

def message_str():
    message = input('Enter Message: ')

    while message:
        new_message += message[-1]
        message = message[:-1]

    print('Your message backwards is:')
    print(new_message)

Revision: 56534
at April 2, 2012 18:20 by jdsantiagojr


Updated Code
# Backwards Message
#
# User enters message and program prints it out backwards

message = input('Enter message: ')
new_message = ''

while message:
    new_message += message[-1]
    message = message[:-1]

print('Your message backwards is:')
print(new_message)

input('\n\nPress enter key to exit.')

Revision: 56533
at April 2, 2012 18:18 by jdsantiagojr


Initial Code
# Backwards Message
#
# User enters message and program returns the message backwards

message = input('Enter message: ')
new_message = ''

while message:
    new_message += message[-1]
    message = message[:-1]

print('Your message backwards is:')
print(new_message)

input('\n\nPress enter key to exit.')

Initial URL

                                

Initial Description
Two ways of printing a message backwards using either string slicing, or list() function.

Initial Title
Backwards Message

Initial Tags
python, 3

Initial Language
Python