fork download
  1. x=[2,4,6,8,10]
  2.  
  3. neighbours = {x1:(x0,x2) for (x0,x1,x2) in zip(x[:-2],x[1:-1],x[2:])}
  4.  
  5. print(neighbours)
Success #stdin #stdout 0.02s 4648KB
stdin
Standard input is empty
stdout
{8: (6, 10), 4: (2, 6), 6: (4, 8)}