I have a list and I need to retrieve the position of the word, so far I have, the word I want to print positions is sea
Sentence = [she , sells , sea , shells ,on , the, sea , shore]
print (sentence.find(sea))
Any idea on what I'm doing wrong?
I have a list and I need to retrieve the position of the word, so far I have, the word I want to print positions is sea
Sentence = [she , sells , sea , shells ,on , the, sea , shore]
print (sentence.find(sea))
Any idea on what I'm doing wrong?
Use the index()
function of lists:
Sentence = ["she" , "sells" , "sea" , "shells" ,"on" , "the", "sea" , "shore"]
print Sentence.index("sea")
The index of lists is zero-based, therefore the result is 2
.