title: How do I get a for loop to iterate over each word in a list of words in python 3
body: <p>I am trying to get this loop to capitalize each word using the capitalize() function</p>
  <p>Here is the code</p>
  <pre><code>def cap(words):
    for j in words:
      print(j)
      return j.capitalize()
  
  s = &quot;my name&quot;
  parts = s.split(&quot; &quot;)
  print(parts)
  it = iter(parts)
  
  capped = cap(parts)
  print(capped)
  
  result = capped.join(&quot; &quot;)
  
  print(capped)
  </code></pre>
  <p>Output:</p>
  <pre><code>['my', 'name']
  my
  My
  My
  </code></pre>
  <p>I am wanting it to return both words capitalized.</p>