Re: [Tutor] Program for outputing the letter backward

2006-03-30 Thread Hoffmann
--- Ed Singleton <[EMAIL PROTECTED]> wrote: > On 29/03/06, Hoffmann <[EMAIL PROTECTED]> wrote: > > --- John Fouhy <[EMAIL PROTECTED]> wrote: > > > > > On 29/03/06, Hoffmann <[EMAIL PROTECTED]> > wrote: > > > > vehicle='car' > > > > index = vehicle[-1] #the last letter > > > > index_zero = ve

Re: [Tutor] Program for outputing the letter backward

2006-03-30 Thread Ed Singleton
On 29/03/06, Hoffmann <[EMAIL PROTECTED]> wrote: > --- 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

Re: [Tutor] Program for outputing the letter backward

2006-03-29 Thread Hoffmann
--- Kent Johnson <[EMAIL PROTECTED]> wrote: > Hoffmann wrote: > > We are almost there. I changed the code and, at > least, > > I got the correct output. However, I also got a > > traceback. I didn't understand the traceback. > Could > > you clarify that? > > Thanks, > > Hoffmann > > ps: The new co

Re: [Tutor] Program for outputing the letter backward - almost there!

2006-03-29 Thread Kent Johnson
Hoffmann wrote: > We are almost there. I changed the code and, at least, > I got the correct output. However, I also got a > traceback. I didn't understand the traceback. Could > you clarify that? > Thanks, > Hoffmann > ps: The new code: > > vehicle='car' index = -1 #index of the last le

Re: [Tutor] Program for outputing the letter backward - almost there!

2006-03-29 Thread Adam
> Hi John, > > We are almost there. I changed the code and, at least, > I got the correct output. However, I also got a > traceback. I didn't understand the traceback. Could > you clarify that? > Thanks, > Hoffmann > ps: The new code: > > >>> vehicle='car' > >>> index = -1 #index of the last lette

Re: [Tutor] Program for outputing the letter backward - almost there!

2006-03-29 Thread Hoffmann
--- Adam <[EMAIL PROTECTED]> wrote: > I just wanted to throw in a couple of ideas for you > on this subject. > These are the ways I would personally think of going > about this > problem: > > >>> ''.join([s[n] for n in range(len(s)-1, -1, -1)]) > 'rac' > Which looks a bit fugly but is nice and sh

Re: [Tutor] Program for outputing the letter backward - almost there!

2006-03-29 Thread Adam
I just wanted to throw in a couple of ideas for you on this subject. These are the ways I would personally think of going about this problem: >>> ''.join([s[n] for n in range(len(s)-1, -1, -1)]) 'rac' Which looks a bit fugly but is nice and short if you can manage list comps. and now my favourite

Re: [Tutor] Program for outputing the letter backward - almost there!

2006-03-29 Thread Hoffmann
--- John Fouhy <[EMAIL PROTECTED]> wrote: > On 29/03/06, Hoffmann <[EMAIL PROTECTED]> wrote: > > Hi John, > > > > (1) vehicle[index] is: 'c' > > (2) If index = index = 1, so vehicle[index] > becomes: > > 'a' > > What I'm getting at here is that, by changing index, > we can change > which letter w

Re: [Tutor] Program for outputing the letter backward

2006-03-28 Thread John Fouhy
On 29/03/06, Hoffmann <[EMAIL PROTECTED]> wrote: > Hi John, > > (1) vehicle[index] is: 'c' > (2) If index = index = 1, so vehicle[index] becomes: > 'a' What I'm getting at here is that, by changing index, we can change which letter we are looking at. And index is a number, which means it's easier

Re: [Tutor] Program for outputing the letter backward

2006-03-28 Thread Hoffmann
--- 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 > > .

Re: [Tutor] Program for outputing the letter backward

2006-03-28 Thread John Fouhy
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

Re: [Tutor] Program for outputing the letter backward

2006-03-28 Thread Hoffmann
--- 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 > >i

Re: [Tutor] Program for outputing the letter backward

2006-03-28 Thread Kent Johnson
Hoffmann wrote: > --- Kent Johnson <[EMAIL PROTECTED]> wrote: > >>You are confusing the index of a letter - the number >>which represents >>its position in the word - with the letter itself. >>In your code, index >>and index_zero are actually letters, not indices. >>Try to rewrite the >>code so

Re: [Tutor] Program for outputing the letter backward

2006-03-28 Thread Hoffmann
--- Kent Johnson <[EMAIL PROTECTED]> wrote: > Hoffmann wrote: > > Hello: > > > > I am trying to write a code (this is an exercose > from > > a book). The goal is to write a program that takes > a > > string and outputs the letters backward, ine per > > line. > > Ok. I did a test first, by writin

Re: [Tutor] Program for outputing the letter backward

2006-03-28 Thread Kent Johnson
Hoffmann wrote: > Hello: > > I am trying to write a code (this is an exercose from > a book). The goal is to write a program that takes a > string and outputs the letters backward, ine per > line. > Ok. I did a test first, by writing a code with > numbers: > > a=0; b=10 > while a<=b: >print

Re: [Tutor] Program for outputing the letter backward

2006-03-28 Thread Hoffmann
--- 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 > >i

[Tutor] Program for outputing the letter backward

2006-03-28 Thread Johnston Jiaa
Hoffman,I am a newbie at python and programming in general so excuse me if I'm wrong.  In your example, you hadwhile index >= index_zero:which I believe to not be what you intended as you are essentially saying:while "last letter of vehicle" >= "first letter of vehicle""e" is respectively "less tha

Re: [Tutor] Program for outputing the letter backward

2006-03-28 Thread Hugo González Monteverde
Hoffmann wrote: > 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? Hi, remember that the condition for the while has to be true. When does index >= index_zero stop being true??? Hope th

Re: [Tutor] Program for outputing the letter backward

2006-03-28 Thread John Fouhy
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

[Tutor] Program for outputing the letter backward

2006-03-28 Thread Hoffmann
Hello: I am trying to write a code (this is an exercose from a book). The goal is to write a program that takes a string and outputs the letters backward, ine per line. Ok. I did a test first, by writing a code with numbers: a=0; b=10 while a<=b: print b b -= 1 Here the output is: 10 9 8