If you look here, it might tell you what you need to know.
Basically, you can create an array from a sequence.
import numpy as np a = np.array( [2,3,4] )
Or from a sequence of sequences.
import numpy as np a = np.array( [[2,3,4], [3,4,5]] )
import numpy as np ... ## other code
some list comprehension
t=[nodel[ nodenext[i][j] ] for j in idx] #for each link, find the node lables #t is the list of node labels
Convert the list to a numpy array using the array method specified in the numpy library.
This may be helpful: https://numpy.org/devdocs/user/basics.creation.html