Say I have a list v = [1, 2, 3, 4, 3, 1, 2]
. I want to write a function, find_pair
which will check if two numbers are in the list and adjacent to each other. So, find_pair(v, 2, 3)
should return True
, but find_pair(v, 1, 4)
should return False
.
Is it possible to implement find_pair
without a loop?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…