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

Hoffmann oasf2004 at yahoo.com
Thu Mar 30 01:22:00 CEST 2006


--- Adam <adam.jtm30 at gmail.com> 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 short if you
> can manage list comps.
> 
> and now my favourite:
> 
> >>> l = list("car")
> >>> l.reverse()
> >>> ''.join(l)
> 'rac'
> 
> hth
> 

Hi Adam,

Defenitely your second alternative is really great! 

Regarding that my 'bad' alternative, do you have any
suggestion about that traceback? I not only would like
to have the exercise done. And after your nice
suggestion, I ALREADY have it, but also I would like
to learn about that traceback I got previously.

Thanks,
Hoffmann


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the Tutor mailing list