I had previously emailed y'all regarding inverting a message input by the user 
of the program backwards. After much contemplation on your earlier replies I 
came up with the code I have included in this email. The problem I am having 
with this code is that the the first character of the message that is reversed 
does not come up. Is there a solution to this? For my message that I input I 
used "take this" to test it, use the same message when the program prompts you 
to enter the message and run it, you'll see what I mean. Also is there a way to 
say reverse the string in a way so the reversed string would result to "this 
take" if you use my example? And is there a way to stop the loop without the 
use of break? Thanks for the help!

Peace,
Raj

My Code:

# Backward message
# program gets message from user then prints it out backwards

message = raw_input("Enter your message: ")

print message

high = len(message)
low = -len(message)

begin=None
while begin != "":
    begin = int(high)

    if begin:
        end = int(low)

        print "Your message backwards is",
        print message[begin:end:-1]
        break


raw_input("\n\nPress the enter key to exit")


      
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to