I have following list (generated after sequence of other functions computations):
[1, 0, 2]
[1, 0, 2]
[0]
[1]
[2]
[1, 0, 2]
[0]
[1]
[2]
[1, 2, 0]
[0, 1]
[2]
[0, 2, 1]
[0, 1, 2]
[0, 1, 2]
[2, 0]
[1]
[2, 0]
[1]
I want to generate a flattened list [1, 0, 2, 1, 0, 2, 0, 1, 2, 1, 0, 2, 0, 1, 2, 1, 2, 0, 0, 1, 2, 2, ....]
. The elements may repeat, but are unequal length at the end (0 might be 10, 1 might be 30, ...).
When I run print([list(i) for i in componentVisited])
I get following error:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-466-0a019fbab5b6> in <module>()
84 numVertices=3
85 xs = linspace(xstart, xend, num=xpts)
---> 86 data = graphLargestComponentSize(numVertices, xs)
87 #data[:20]
88
<ipython-input-466-0a019fbab5b6> in graphLargestComponentSize(n, theRange)
72
73 def graphLargestComponentSize(n, theRange):
---> 74 return [(p, sizeOfLargestComponent(randomGraph(n, p))) for p in theRange]
75
76
<ipython-input-466-0a019fbab5b6> in sizeOfLargestComponent(vertices)
68 def sizeOfLargestComponent(vertices):
69
---> 70 return max(len(c) for c in connectedComponents(vertices))
71
72
<ipython-input-466-0a019fbab5b6> in connectedComponents(vertices)
42 components.append(componentVisited)
43 cumulativeVisited |= componentVisited
---> 44 print([list(i) for i in componentVisited])
45 from itertools import chain
46 newlist=[i for i in componentVisited]
TypeError: iteration over non-sequence
Any help to solve this mystery would be great.