I have a list and want to check if a given sequence exist in the list or not.
For example the given sequence is 'a','h','z'
and the list is l = ['a','b','h','g','z']
. Given that in the list z comes after h after a, I need the code returns True value.
def check_for_a_h_z(seq):
return ('a','h','z') in zip(seq, seq[1:], seq[2:])
The code return true if only 'a','h','z'
are coming exactly after each other.