I am doing homework and I got stuck with my code. The question is about two lists containing string letters in it as elements and we want to know how many times the small text occurs in the long one.(with order)
Example: long=['a','k','g','j','a','k','k','a','k','g']
small=['a','k','g']
then the answer should be 2 as it occurs twice(first and in the last part) As I tried:
def search(long,small):
words=[]
for k in range(len(long)):
for l in range(len(small)):
if long[k]==small[l]:
words.append()
return(words)
First tried to write down the matches in the list and then divide the len of list to get the number. But unfortunatly this gives me the first match and i am not sure how to get all the matches. Hope you guys can help me.