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

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -