title: How to use yield function in python
body: <p>SyntaxError: 'yield' outside function</p>
  
  <pre><code>&gt;&gt;&gt; for x in range(10):
  ...     yield x*x
  ... 
    File "&lt;stdin&gt;", line 2
  SyntaxError: 'yield' outside function
  </code></pre>
  
  <p>what should I do? when I try to use simple yield in for loop.</p>