title: Google's Python Course: iterating through list of regular expressions and printing each output on a new line
body: <p>I am trying to pass some regular expressions examples that are provided by Google's Python Course to a list and print each output on a new line.</p>
  
  <pre><code>import re
  str='an example word:cat!!'
  match=re.search(r'word:\w\w\w',str)
  if match:
    print('I found a cat :)',match.group()) ## 'found word:cat'
  else:
    print('did not find')
  
  
  matches=[re.search(r'pi+', 'piiig'),re.search(r'i+', 'piigiiii'),re.search(r'\d\s*\d\s*\d', 'xx1 2   3xx'),re.search(r'\d\s*\d\s*\d', 'xx12  3xx'),re.search(r'\d\s*\d\s*\d', 'xx123xx'),re.search(r'^b\w+', 'foobar'),re.search(r'b\w+', 'foobar')]
  for the_match in matches:
    matches.append(the_match)
  print("\n".join(matches))
  #del matches
  </code></pre>
  
  <p>When I run <code>python regex.py</code>, I get the following:</p>
  
  <pre><code>python regex.py
  I found a cat :) word:cat
  </code></pre>
  
  <p>It just stalls and produces no further output. I will have to press <code>ctrl+c</code> 2 times to exit. </p>
  
  <p>Please let me how to get an output such as:</p>
  
  <pre><code>re.search(r'pi+', 'piiig') returned (&lt;_sre.SRE_Match object; span=(0, 4), match='piii'&gt;, &lt;_sre.SRE_Match object; span=(1, 3), match='ii'&gt;)
  re.search(r'i+', 'piigiiii') returned &lt;_sre.SRE_Match object; span=(1, 3), match='ii'&gt;
  etc...
  </code></pre>
  
  <p>I am running Python 3.5.2 on Windows 10 version 10.0.10586 64 bit.</p>
  
  <p>Thank you!</p>
  
  <p>After your answers (@Buzz), my script is as follows:</p>
  
  <pre><code>import re
  str='an example word:cat!!'
  match=re.search(r'word:\w\w\w',str)
  matches=[re.search(r'pi+', 'piiig'),re.search(r'i+', 'piigiiii'),re.search(r'\d\s*\d\s*\d', 'xx1 2   3xx'),re.search(r'\d\s*\d\s*\d', 'xx12  3xx'),re.search(r'\d\s*\d\s*\d', 'xx123xx'),re.search(r'^b\w+', 'foobar'),re.search(r'b\w+', 'foobar')]
  
  if match:
    print('I found a cat :)',match.group()) ## 'found word:cat'
  else:
    print('No match found.')
  
  for the_match in matches:
    print(the_match)
  </code></pre>
  
  <p>The output is as follows:</p>
  
  <pre><code>I found a cat :) word:cat
  &lt;_sre.SRE_Match object; span=(0, 4), match='piii'&gt;
  &lt;_sre.SRE_Match object; span=(1, 3), match='ii'&gt;
  &lt;_sre.SRE_Match object; span=(2, 9), match='1 2   3'&gt;
  &lt;_sre.SRE_Match object; span=(2, 7), match='12  3'&gt;
  &lt;_sre.SRE_Match object; span=(2, 5), match='123'&gt;
  None
  &lt;_sre.SRE_Match object; span=(3, 6), match='bar'&gt;
  </code></pre>
  
  <p>This works perfectly. Thank you so much.</p>