[Tutor] flattening a list

Mario Rol mario_rol at hotmail.com
Thu Jan 13 00:08:23 CET 2005


nice and concise, found on comp.lang.python:

def flatten(a):
    if not isinstance(a,(tuple,list)): return [a]
    if len(a)==0: return []
    return flatten(a[0])+flatten(a[1:])

_________________________________________________________________
Play online games with your friends with MSN Messenger 
http://messenger.msn.nl/



More information about the Tutor mailing list