DawidBellam DawidBellam - 1 year ago 61
Python Question

How do I have items in a list be correspondent to integers?

As the title says, how do I do that?

Answer Source

This should work:

sentence = "WHAT IS MINE IS YOURS AND WHAT IS YOURS IS MINE";    
sentence = sentence.lower();
sentence = sentence.split();

uniqueWord = [];

for i in sentence:
    if i not in uniqueWord:
        uniqueWord.append(i);

for word in sentence:
    print uniqueWord.index(word) + 1

Here it is the link to the documentation of index