I am trying to understand a small program
def flatten(nested):
try:
for sublist in nested:
for element in flatten(sublist):
yield element
except TypeError:
yield nested
I want to know when is the TypeError:yield nested statement (last 2 lines) work in the program ,I read python docs tutotrial about TypeError but I could not understand any thing the input to the program is some thing like this [[[1], 2], 3, 4, [5, [6, 7]], 8]