[Tutor] Program for outputing the letter backward
john at fouhy.net
Wed Mar 29 02:22:36 CEST 2006
On 29/03/06, Hoffmann <oasf2004 at yahoo.com> wrote:
> index = vehicle[-1] #the last letter
> index_zero = vehicle #the first letter
> while index >= index_zero:
> print letter
> index -= 1
> The problem is that I get no output here. Could I hear
> from you?
I can print the letters backwards like this:
vehicle = 'car'
This is not very useful, though, because it will only work for strings
that are exactly three letters long. Can you see how to write a loop
to produe this output?
Hint: the len() function will tell you how long a string is.
eg: if vehicle == 'car' then len(vehicle) == 3.
More information about the Tutor