How do you retrieve a position of a word from a list?
This question already has an answer here:
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
.
上一篇: 无法在Lion下使用RVM安装Ruby - GCC问题
下一篇: 你如何从列表中检索单词的位置?