title: 'for' loop in one line in Python
body: <p>When I tried to use a <em>for</em> statement in one line like below,</p>
  <pre><code>def get_cubes(x):
  ls=[]
  ls.append(pow(item*3, 3)) for item in range(int((x-x%3)/3)+1)
  return ls
  </code></pre>
  <p>there was always an error:</p>
  <pre><code>File &quot;&lt;ipython-input-47-8c391c3d568a&gt;&quot;, line 3
  ls.append(pow(item*3, 3))  for item in range(int((x-x%3)/3)+1)
                               ^
  SyntaxError: invalid syntax
  </code></pre>
  <p>But when I write it in a regular <em>for</em> loop method, it works well. Why?</p>