Given a list of floats with the name 'x', I would like to create a dictation for each x in x [1: -1] for its neighbors using a dict understanding. I tried the following line:
neighbours = {x1:(x0,x2) for (x0,x1,x2) in zip(x[:-2],x[1:-1],x[2:])}
However, the syntax seems invalid. What am I doing wrong?
Chris source
share