Newbi Q: Recursively reverse lists but NOT strings?

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Wed Oct 17 00:16:27 CEST 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