Im trying to code a program where the user enters a message and it is returned 
backwards. Here is my code so far:
 



 
message = input("Enter your message: ")
 
backw = ""
counter = len(message)
 
while message != 0:
    backw += message[counter-1]
    counter -= 1
print(backw)
input("\nPress enter to exit...")
 



 
I run the program, type in my message but get back the error code:
 
'IndexError: String out of range'
 
I was thinking that maybe the problem is that each time a letter is taken from 
'message' and added to 'backw', the length of message becomes a letter shorter 
but for whatever reason the variable 'counter' doesnt change when its supposed 
to be minused by 1 letter so its always bigger than message if that makes 
sense. Any help is much appreciated and thanks in advance.

Myles Broomes
                                          
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to