2019-03-20

a = [1,2,3,45,6,17,8,90,8,6,4,5,6,7,0,6]
target = 10
cache = {}
for index,i in enumerate(a):
    if target-i in cache.keys():
        print('a[{}]:{} and a[{}]:{}'.format(index,i,cache[target-i],target-i))
        break
    cache[i]=index   

你可能感兴趣的:(2019-03-20)