How do you retrieve a position of a word from a list?

This question already has an answer here:

  • Finding the index of an item given a list containing it in Python 23 answers

  • 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 .

    链接地址: http://www.djcxy.com/p/28130.html

    上一篇: 无法在Lion下使用RVM安装Ruby - GCC问题

    下一篇: 你如何从列表中检索单词的位置?