So I have this list:

```
list = ["NYC Football", ["NY Giants","NY Jets"], "NYC Hockey", ["NY Rangers", "NY Islanders", "NJ Devils"]]

```

How would I loop through this list and only print out:

```
NY Giants
NY Jets
NY Rangers
NY Islanders
NJ Devils

```
['https://Stackoverflow.com/questions/35507451', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/-1/']
First of all, please don't use the name list for a list. You will shadow the built in list, which is going to give you a hard to detect bug sooner or later.

As chepner already mentioned in the comments, I strongly recommend converting your list to a dictionary in order to have a clean sport:teams mapping.

```
>>> lst = ["NYC Football", ["NY Giants","NY Jets"], "NYC Hockey", ["NY Rangers", "NY Islanders", "NJ Devils"]]
>>> teams = dict(zip(*[iter(lst)]*2))
>>> teams
{'NYC Football': ['NY Giants', 'NY Jets'], 'NYC Hockey': ['NY Rangers', 'NY Islanders', 'NJ Devils']}

```

To get the sports, issue

```
>>> teams.keys()
['NYC Football', 'NYC Hockey']

```

To get the teams, issue

```
>>> teams.values()
[['NY Giants', 'NY Jets'], ['NY Rangers', 'NY Islanders', 'NJ Devils']]

```

You could also un-nest this list with `itertools.chain`:

```
>>> list(chain.from_iterable(teams.values()))
['NY Giants', 'NY Jets', 'NY Rangers', 'NY Islanders', 'NJ Devils']

```

I assumed that the order of the dictionary is not important. If it is, you can use an `OrderedDict` from the `collections` module.

```
>>> from collections import OrderedDict
>>> teams = OrderedDict(zip(*[iter(lst)]*2))
>>> for team in chain.from_iterable(teams.values()):
...     print(team)
... 
NY Giants
NY Jets
NY Rangers
NY Islanders
NJ Devils

```
Loop over the outer list, and only if the item is a list, iterate over it and print its items:

```
for thing in my_list: #don't call it "list"
    if isinstance(thing, list):
        for other in thing:
            print(other)

```

Another way:

```
for thing in filter(lambda x: isinstance(x, list)):
    for other in thing:
        print(other)

```