Created
September 4, 2018 03:10
-
-
Save zimmerrol/30006aacdc4d658b71faede641d81070 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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