for elt in itertools.chain.from_iterable(node): if elt is the last element: do statement
How do I achieve this
I do something like this:
rng = len(mlist) for i in range(rng): foo = mlist[i] foo.do_something_for_every_item_regardless() if i == rng - 1: #since we go from 0 to rng-1 foo.last_item_only_operation()