--- 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
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
--- 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
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
> 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
--- 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
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
--- 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
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
--- 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
> > .
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
--- 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
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
--- 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
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
--- 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
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
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
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
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
20 matches
Mail list logo