[Tutor] Python backwards program
Danny Yoo
dyoo at hkn.eecs.berkeley.edu
Wed Apr 13 04:09:55 CEST 2005
On Wed, 13 Apr 2005, Tony Meyer wrote:
> > 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.
It might also help to have a better feeling for what Jim already knows.
If this is a school assignment, I doubt that reversed() is allowed, nor
reverse slices, since that would make the problem too easy. *cough*
Jim, can you give a brief description of what things you've learned
already? Do you already know about loops?
More information about the Tutor
mailing list