python 3.x - Define function that reads from Lists of lists -
heres quick example:-
setup = [['dog','red','big','ears'], ['cat','blue','small','tail']] def do_it(dummy_parameter): if do_it [0][0] == 'dog': print 'dog' elif do_it [0][0] == 'cat' print 'cat' do_it(setup)
basically looking go through list of 4 lists, make action depending on each of list contents.. bit vague assistance appreciated! :)
getting error
typeerror: 'function' object has no attribute '__getitem__'
here example how values list , list of list :) recursion :)
test = [['a', 'b', 'c'],['d', 'e'], 'f'] def separate(item): try: in item: if type(i) == list: separate(i) else: print(i) except indexerror: pass separate(test)
Comments
Post a Comment