Concatenation of many lists in Python
Posted
by Space_C0wb0y
on Stack Overflow
See other posts from Stack Overflow
or by Space_C0wb0y
Published on 2010-06-11T09:22:54Z
Indexed on
2010/06/11
9:32 UTC
Read the original article
Hit count: 175
Suppose i have a function like this:
def getNeighbors(vertex)
which returns a list of vertices that are neighbors of the given vertex. Now i want to create a list with all the neighbors of the neighbors. I do that like this:
listOfNeighborsNeighbors = []
for neighborVertex in getNeighbors(vertex):
listOfNeighborsNeighbors.append(getNeighbors(neighborsVertex))
Is there a more pythonic way to do that?
© Stack Overflow or respective owner