[Tutor] Python backwards program
Tony Meyer
tameyer at ihug.co.nz
Wed Apr 13 03:15:14 CEST 2005
> I am very new to programming and I have an assignment
> to have a raw_input string that is inputted by the user
> and then is printed backwards. Can anyone help me? I can
> get it to print regular but backwards in not working.
I guess that I shouldn't give code if this is for an assignment, but if you
are using Python 2.4, then try seeing what the "reversed()" built-in
function does. If you're not using Python 2.4, then read up about "slices"
- which is when you get subsections of a string (e.g. "tony"[2:4] is "ny").
You can pass a 'direction' in a slice as well.
=Tony.Meyer
More information about the Tutor
mailing list