Recursively traverse linked list -- help!

Mike Carifio carifio.nospam at nospam.usys.com
Wed Feb 20 01:35:14 CET 2002


# simple is good too

def traverse(list):
    if list:
        print list[0]  # or do something here
        traverse(list[1:])
    else:
        print "done"

# even simplier

def traverse1(list):
    if list:
        # do something
        traverse(list[1:])





More information about the Python-list mailing list