--- John Fouhy <[EMAIL PROTECTED]> wrote: > 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. > _______________________________________________
Hi John and the other colleagues from the Tutor, I still didn't realized how to solve this exercise. Regarding the for loop. I can do that for the "forward" version of the program. See below: name = 'car' for char in name: print char However, I still write a "backward" version (in order to get r a c Could you guys, please, continue talking to me? Thanks! Hoffmann __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor