0

Let's say I have a dictionary with several lists and tuples, and I wanted to loop over all of the dictionary's items, and also loop over all of the dictionary's tuples and lists too (so as to just get the values and keywords) is there a way to do it other than just defining a bunch of for loops?

I.e.:

def islist(arg):
    if type(arg) == list or tuple:
        #loop
        for i in arg:
            if type(i) == list or tuple:
                #again
                for i in arg:
                    if type(i) == list or tuple:
                        #again
Startec
  • 12,496
  • 23
  • 93
  • 160
  • Aside: `type(arg) == list or tuple` doesn't do what I think you think it does. Read the answer to [this question](http://stackoverflow.com/questions/20002503/why-does-a-b-or-c-or-d-always-evaluate-to-true) for an explanation. – DSM Aug 08 '14 at 03:13
  • http://stackoverflow.com/a/2158532/645956 – grc Aug 08 '14 at 03:34

0 Answers0