Я не уверен на 100%, где у вас возникла проблема, но на основании первоначального описания вы можете использовать функцию списка index
для определения местоположения значения.
Затем вы можете увеличить значение индекса на длину найденного там слова.
Перед добавлением найденного значения в список проверьте, существует ли оно там и - если оно существует - пропустите его.
song = ["Es", "gingen", "zwei", "Parallelen",
"ins", "Endlose", "hinaus",
"zwei", "kerzengerade", "Seelen",
"und", "aus", "solidem", "Haus",
"Sie", "wollten", "sich", "nicht", "schneiden",
"bis", "an", "ihr", "seliges", "Grab",
"Das", "war", "nun", "einmal", "der", "beiden",
"geheimer", "Stolz", "und", "Stab",
"Doch", "als", "sie", "zehn", "Lichtjahre",
"gewandert", "neben", "sich", "hin", #hin[42]
"da", "wards", "dem", "einsamen", "Paare",
"nicht", "irdisch", "mehr", "zu", "Sinn",
"Warn", "sie", "noch", "Parallelen",
"Sie", "wußtens", "selber", "nicht",
"sie", "flossen", "nur", "wie", "zwei", "Seelen",
"zusammen", "durch", "ewiges", "Licht",
"Das", "ewige", "Licht", "durchdrang", "sie",
"da", "wurden", "sie", "eins", "in", "ihm",
"die", "Ewigkeit", "verschlang", "sie",
"als", "wie", "zwei", "Seraphim"]
#word = input("Enter a word")
word = "zwei" # The input
found_list = [] # The list for found words
index = song.index(word) # Get the index of the first instance of "word"
while True: # Keep running until "break"
try: # This will throw an error when index is out of range
# If the word at index is not already in found_list, add it
if song[index] not in found_list:
found_list.append(song[index])
# regardless of whether you add the found word,
# increment the index by the length of the found word
index += len(song[index])
except:
break
print(found_list)
ВЫХОД:
['zwei', 'hinaus', 'solidem', 'bis', 'seliges', 'beiden', 'als', 'Lichtjahre', 'nicht', 'Warn', 'Sie', 'ewiges', 'sie', 'ihm', 'verschlang']