title: Python: For loop not working properly
body: <p>Why is the for loop not working properly? It's just returned only one element.</p>
  
  <p>1.</p>
  
  <pre><code>rx = ['abc', 'de fg', 'hg i']
  def string_m(a=rx):
       for i in a:
           l = re.sub(" ","/",i)
           r = l.split("/")
           r.reverse()
           rx = " ".join(r)
           return rx
  a=string_m(rx)
  print(a)
  </code></pre>
  
  <p>Outputs:</p>
  
  <pre><code>abc
  </code></pre>
  
  <p>2.</p>
  
  <pre><code>rx = ['abc', 'de fg', 'hg i']
  def string_m(a=rx):
       for i in a:
           l = re.sub(" ","/",i)
           r = l.split("/")
           r.reverse()
           rx = " ".join(r)
       return rx
  a=string_m(rx)
  print(a)
  </code></pre>
  
  <p>Outputs:</p>
  
  <pre><code>i hg
  </code></pre>
  
  <p>-- Can someone help me to see what I am doing wrong?</p>