Edges = [ [0,1],[1,2],[2,3],[3,0], [4,5],[5,6],[6,7],[7,4], [0,4],[1,5],[2,6],[3,7] ] numbered_vertex = 1 # where 1 is an arbitrary choice of vertex for i in Edges: if numbered_vertex in i: print(i)
or this way..a little bit more confusing at first.. but ultimately not too unwieldy.
Edges = [ [0,1],[1,2],[2,3],[3,0], [4,5],[5,6],[6,7],[7,4], [0,4],[1,5],[2,6],[3,7] ] n = 1 # where 1 is an arbitrary choice of vertex print([x for x in Edges if x[0] == n or x[1] == n]) # or print([x for x in Edges if n in x])