I am trying to find how to print the indexes of words in a list in Python. If the sentence is "Hello world world hello name") I want it to print the list "1, 2, 2, 1, 3")
I removed all duplicates of words with this:
sentence = input("Enter").lower()
words = sentence.split()
counts = []
for word in words:
if word not in counts:
counts.append(word)
print(counts)
But I need to still get indexes of the sentence using an array
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…