1

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?

Ash Jaimal
  • 19
  • 3
  • 1
    Welcome to Stack Overflow! You seem to be asking for someone to write some code for you. Stack Overflow is a question and answer site, not a code-writing service. Please [see here](http://stackoverflow.com/help/how-to-ask) to learn how to write effective questions. – Morgan Thrapp Jan 21 '16 at 18:21
  • Honestly, this is a pretty simple question with a simple solution. I don't think it deserves downvotes or to be closed except for the fact that it is a duplicate. – Vorticity Jan 21 '16 at 18:23

1 Answers1

1

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.

jofel
  • 3,297
  • 17
  • 31