This should be an easy and simple problem to solve. I'm trying to iterate through my nested list and remove any lists that are below a certain length.
for i in connections:
if(len(i) >= 3):
continue
else:
connections.remove(i)
This is the nested list:
[[55, 35, 19, 1], [2, 78], [3, 78], [6, 78], [], [], [8, 7, 78], [9, 78], [9, 78], [10, 78], [12, 11, 78], [13, 78], [13, 78], [14, 78], [16, 15, 78], [17, 78], [18, 78], [75, 78], [75, 78], [21, 20, 78], [23, 22, 78], [23, 22, 78], [24, 78], [24, 78], [25, 78], [26, 78], [29, 28, 78], [], [30, 78], [30, 78], [31, 78], [33, 32, 78], [34, 78], [34, 78], [76, 78], [36, 78], [39, 38, 78], [], [40, 78], [40, 78], [41, 78], [43, 42, 78], [44, 78], [44, 78], [46, 45, 78], [47, 78], [47, 78], [48, 78], [50, 49, 78], [51, 78], [51, 78], [53, 52, 78], [54, 78], [54, 78], [77, 78], [56, 78], [59, 58, 57, 78], [60, 78], [60, 78], [60, 78], [61, 78], [63, 78], [], [64, 78], [66, 65, 78], [67, 78], [67, 78], [69, 68, 78], [70, 78], [70, 78], [72, 71, 78], [73, 78], [73, 78], [74, 78], [78], [78], [78], [78], []]
and here is what the above code gets me:
[[55, 35, 19, 1], [3, 78], [8, 7, 78], [9, 78], [12, 11, 78], [13, 78], [16, 15, 78], [18, 78], [75, 78], [21, 20, 78], [23, 22, 78], [23, 22, 78], [24, 78], [26, 78], [29, 28, 78], [30, 78], [31, 78], [33, 32, 78], [34, 78], [36, 78], [39, 38, 78], [], [40, 78], [41, 78], [43, 42, 78], [44, 78], [46, 45, 78], [47, 78], [50, 49, 78], [51, 78], [53, 52, 78], [54, 78], [56, 78], [59, 58, 57, 78], [60, 78], [61, 78], [], [66, 65, 78], [67, 78], [69, 68, 78], [70, 78], [72, 71, 78], [73, 78], [78], [78], []]
It does catch some of them, but you can see that there are still elements in there that have less than 3 elements in them. I'm genuinely stumped by this.