3. 16. 4. flatten generator rewritten as a plain function
def flatten(nested):
result = [] try: try: nested + ''
except TypeError: pass else: raise TypeError for sublist in nested: for element in flatten(sublist):
result.append(element)
except TypeError:
result.append(nested) return result