Check if an item is iterable and iterate over it. Very nice for nested lists where you are unsure how many 'levels' of nested lists there are
def iterate(data, indentation):
if isinstance(data, dict):
for key, value in data:
print(key)
if is_iterable(value):
iterate(value, indentation+indent)
else:
passfrom collections import Iterable
def is_iterable(data):
if isinstance(value, Iterable):
return True
else:
return False