I am wondering how to convert words from an input into values in Python. The user would enter an input for example:
"The dog chased the cat the lion chased the dog"
I would then like it to return:
["1,2,3,1,4,1,5,6,1,2"]
I would like duplicate words to retain the same value as when the word first occurred. I have tried to do this multiple ways, I am using the following code at the moment, but it seems to return random indexes:
l = input("Enter a sentence").lower lists= list(l) valueindex = range(len(lists)) print(valueindex)
Thanks for the help, Izaak