[Tutor] how to print a message backwards

Alan Gauld alan.gauld at btinternet.com
Wed Sep 23 19:51:26 CEST 2009


"Ali Sina" <seena_blk at yahoo.com> wrote 

#Message backward printer
message=input('Enter your message: ')

for i in range(len(message),0,-1):
print(message)


> This is the code which I have written. 
> All it does is count the number of letters starting from backwards. 

Correct, plus it prints the original message each time.
So obviously you need to print something else! If you are counting 
one letter at a time maybe you should print one letter at a time?

However/...
Others have given you a big hint about using slicing instead 
so I'll leave you to research that yourself.


-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/




More information about the Tutor mailing list