[Tutor] Help needed

Lie Ryan lie.1296 at gmail.com
Tue Jun 16 23:58:14 CEST 2009


Raj Medhekar wrote:
> So I figured out the solution to the missing letter and I will post my
> code here. But I still need help figuring out the other stuff (please
> see my original message included in this email)! Thanks for putting up
> with me. Python is slowly but surely coming to me! I am psyched since
> this is the first programming language that I am learning! Thanks all
> for the assistance!
> 
> -Raj
> 
> New 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[::-1]
>         break
> 
> 
> raw_input("\n\nPress the enter key to exit")
> 

All that can be simplified to two lines:
message = raw_input("Enter your message: ")
print "Your message backwards is", message[::-1]



More information about the Tutor mailing list