--- John Fouhy <[EMAIL PROTECTED]> wrote: > On 29/03/06, Hoffmann <[EMAIL PROTECTED]> wrote: > > >>> vehicle='car' > > >>> index = 0 > > >>> lenght =len(vehicle) > > >>> last = vehicle[lenght -1] > > >>> while last >= vehicle[0]: > > ... letter = vehicle[index] > > ... print letter > > ... last -= 1 > > ... > > What is vehicle[index] ? > > What if I change index, say, > > index = index + 1 > > Now what is vehicle[index] ? > > -- > John. > _______________________________________________
Hi John, (1) vehicle[index] is: 'c' (2) If index = index = 1, so vehicle[index] becomes: 'a' I changed a bit more the code, but I am still in trouble. please, take a look: (1st. try): >>> vehicle='car' >>> index = vehicle[-1] #'r' >>> lenght =len(vehicle) # 3 leters >>> last = vehicle[lenght -1] # >>> while last >= vehicle[0]: ... letter = vehicle[index] ... print letter ... last -= 1 ... Traceback (most recent call last): File "<stdin>", line 2, in ? TypeError: string indices must be integers (2nd, try): >>> vehicle='car' >>> index = vehicle[-1] >>> while vehicle[-1] >= vehicle[0]: ... letter = vehicle[index] ... print letter ... index -= 1 ... Traceback (most recent call last): File "<stdin>", line 2, in ? TypeError: string indices must be integers Such a 'hard' simple problem... 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