Newbi Q: Recursively reverse lists but NOT strings?

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Tue Oct 16 18:16:27 EDT 2007


Bruno Desthuilliers a écrit :
> <OT>answering to Dmitri O.Kondratiev<OT>
(snip)
> 
> def reverse(xs):
>   if xs:
>     return xs
 >   else:
 >     return (reverse (xs[1:])) + [xs[0]]

I meant:

def reverse(xs):
   if not xs:
(etc...)

of course...

<ot mode='private joke>'
  story stargaming, I caught it first this time !-)
<*ot>



More information about the Python-list mailing list