title: Why looping directly through the list/array doesn't work for linear search but works when the condition is by range
body: <p>I am trying to do a simple linear search through an array/list by asking user for a input then use a 'for loop' to compare return the index.</p>
  <p>The loop in the code below works!</p>
  <pre><code>names = ['jon', 'eren', 'maria', 'colt']
  
  keyword = input(&quot;enter to search in names &quot;)
  
  for n in range(0, len(names)):
      if keyword == names[n]:
          print(n)
  </code></pre>
  <p>but when I replace the first line of the loop (btw whats it called?)</p>
  <pre><code>for n in names:
      if keyword == names[n]:
          print(n)
  </code></pre>
  <p>It throws a error on the if statement line</p>
  <p><em>TypeError: list indices must be integers or slices, not str</em></p>
  <p>Why is that?  How is that different?</p>