[Tutor] Python backwards program (fwd)
dyoo at hkn.eecs.berkeley.edu
Thu Apr 14 20:52:12 CEST 2005
> Does the 2.2 python have the ability to do this?
Python 2.2 is actually a bit old; you may want to update the version of
Python on your system to Python 2.4. You can find it here:
A lot of the approaches you were trying earlier used features that were
added in the 2.3 or 2.4 Python series; they're absent from Python 2.2.
> The following gives me the last letter of the string.
> backwords=raw_input("enter number or string:")
> print backwords[-1]
Yes, this is an interesting approach! We can go along this approach a
little more, if you'd like. The code above is getting the last letter, so
we're closer to printing out the word backwards.
How would you print out the second to last letter of the string?
More information about the Tutor