Making a Generator : Yield : Statement PYTHON TUTORIALS


PYTHON TUTORIALS » Statement » Yield »

 

Making a Generator


def flatten(nested):
    for sublist in nested:
        for element in sublist:
            yield element
nested = [[12][34][5]]
for num in flatten(nested):
    print num

print list(flatten(nested))



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo Statement
» Yield