I have a list of lists containing numbers as follows:
scc = [[6], [17, 7], [11, 10, 20, 1], [8, 18, 22, 13, 3], [4, 14, 23, 28, 9, 27, 19, 25, 24, 5, 15, 31, 30, 12, 26, 21, 2]]
and a used numbers list as follows:
used = [6,7,20,4]
and I want to remove those used numbers from scc list of lists and if any list boils down to one element and I want to remove that element from it I want to remove the whole list from scc.
scc = [[number for number in group if number not in used] for group in scc]
scc = [[], [17], [11, 10, 20, 1], [8, 18, 22, 13, 3], [14, 23, 28, 9, 27, 19, 25, 24, 5, 15, 31, 30, 12, 26, 21, 2]]
but I want to remove the list in scc if it's length is == 0 like the first list so that scc would be outputed as that:
scc = [[17], [11, 10, 20, 1], [8, 18, 22, 13, 3], [14, 23, 28, 9, 27, 19, 25, 24, 5, 15, 31, 30, 12, 26, 21, 2]]
Is there an elegant way to do it?