下面是一个简单的工作代码:
test = [3,5,7,1,10,17] def neighbor_splitting(): for x in test: if x == 10: index = test.index(x) list1 = test[:index] list2 = test[index:] return list1, list2 # [3, 5, 7, 1] # [10, 17]