On 29/03/06, Hoffmann <[EMAIL PROTECTED]> wrote: > vehicle='car' > index = vehicle[-1] #the last letter > index_zero = vehicle[0] #the first letter > > while index >= index_zero: > letter=vehicle[index] > 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' print vehicle[2] print vehicle[1] print vehicle[0] Output: r a c ----- 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. -- John. _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor