I've created this function that looks for sequences in a list. If [1,2,3]
exists, it will print True
. I've tested the code and it works fine.
def looking_patt(pattern,cursor,found):
big_s = []
for i in range(1,101):
if i % 10 == 0:
big_s.extend([1,2,3])
else:
big_s.append(i)
# check control
print(big_s)
for i in big_s:
if i == pattern[cursor]:
cursor += 1
if cursor == len(pattern):
found.append(pattern)
print(found)
cursor = 0
else:
cursor = 0
print(len(found) > 0)
Part of the script (the for i in big_s:
) has been taken from an answer in this SO question.
How can it be improved?