Skip to content

Instantly share code, notes, and snippets.

@zimmerrol
Created September 4, 2018 03:10
Show Gist options
  • Save zimmerrol/30006aacdc4d658b71faede641d81070 to your computer and use it in GitHub Desktop.
Save zimmerrol/30006aacdc4d658b71faede641d81070 to your computer and use it in GitHub Desktop.
parent = ['heute', 'sitze', 'ich', 'hier', 'und', 'morgen', 'sitze', 'ich', 'auch', 'dort']
child = ['sitze', 'ich', 'auch']
def search(parent, child):
found = False
for i in range(len(parent)):
if parent[i] == child[0]:
found = True
for j, word in enumerate(child):
if word != parent[i+j]:
found = False
break
if found:
return i
return -1
search(parent, child)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment