python - Printing items within a list within a list, etc. (Printing nested lists) -
i'm trying write function print:
file1 file2 file3 file4 file5 file6 file7
when enter:
c = [['file1', [['file2']], ['file3', 'file4', 'file5']], 'file6', ['file7']]
it's supposed directory.
here code:
def tree_traverse(directory) : list1 = list(directory) in list1 : if == 'cc' : del(list1[:(list1[it]+3)]) item in directory : print(item)
whenever enter input above, error saying c unexpected argument. also, when enter above input without "c = ", prints entered it. i'm quite lost @ do.
this flattens list want.
c = [['file1', [['file2']], ['file3', 'file4', 'file5']], 'file6', ['file7']] def getfiles(container): f in container: if isinstance(f, list): farray in getfiles(f): yield farray else: yield f print "".join("%s\n" %f f in list(getfiles(c)))
Comments
Post a Comment