title: Find words in a sentence and its index position using a for loop
body: <p>I am writing a code that prompts the user to enter a sentence which is then defined as <code>str1</code> and then is prompted to enter a word defined as <code>str2</code>.</p>
  
  <p>For example:</p>
  
  <pre><code>Please enter a sentence: i like to code in python and code things
  Thank you, you entered:  i like to code in python and code things
  Please enter a word: code
  </code></pre>
  
  <p>I want to use a <code>for</code> loop to find <code>str2</code> in <code>str1</code> to print whether the word is or is not found, and if it has been found, the index position(s) of <code>str2</code>.</p>
  
  <p>Currently I have this code:</p>
  
  <pre><code>str1Input = input("Please enter a sentence: ")
  print("Thank you, you entered: ",str1Input)
  
  str1 = str1Input.split()
  
  str2 = input("Please enter a word: ")
  
  if str2 in str1:
      for str2 in str1:
          print("That word was found at index position", str1.index(str2)+1)
  else:
      print("Sorry that word was not found")
  </code></pre>
  
  <p>Although, the outcome appears to print whether or not the index position was found but then prints the index position of every word inside the sentence. Also if I am searching of a certain word that appears twice in that sentence, it just prints the index position of the first time the word is seen in the sentence, for example:</p>
  
  <pre><code>Please enter a sentence: i like to code in python and code things
  Please enter a word: code
  Thank you, you entered:  i like to code in python and code things
  
  
  That word was found at index position: 1
  That word was found at index position: 2
  That word was found at index position: 3
  That word was found at index position: 4
  That word was found at index position: 5
  That word was found at index position: 6
  That word was found at index position: 7
  That word was found at index position: 4
  That word was found at index position: 9
  </code></pre>
  
  <p>If anyone could help me and anyone else attempting something similar to this that would be extremely helpful!</p>