title: Multi-variable List Comprehension
body: <p>I am working on <a href="http://projecteuler.net/problem=35">Project Euler #35</a>, and I need to find the circular permutations of a number. Using <code>itertools</code>, I can easily get the permutations of a number. However, I want to do it with a list comprehension (as it seems more Pythonic; I am also trying to get familiar with list comprehensions).</p>
  
  <p>I found that all circular primes can only contain the digits 1, 3, 7, and 9 (this excludes 2 and 5, which are circular primes by definition). If any other digit was in the number (0, 2, 4, 5, 6, or 8) one of the permutations would not be a prime (as that digit would be last in at least one of the permutations).</p>
  
  <p>Thus, I tried doing this:</p>
  
  <pre><code>from itertools import permutations
  l = [x for x in list(permutations('1397', y)) for y in range(7)]
  </code></pre>
  
  <p>I needed to use <code>y for y in range(7)</code> so that I get varying lengths of permutations.</p>
  
  <p>However, this gave me a <code>TypeError</code>:</p>
  
  <pre><code>Traceback (most recent call last):
    File "&lt;pyshell#23&gt;", line 1, in &lt;module&gt;
      l = [x for x in list(permutations('1397', y)) for y in range(7)]
  TypeError: an integer is required
  </code></pre>
  
  <p>This works, but it isn't using two variables in one list comprehension:</p>
  
  <pre><code>l = []
  for y in range(7):
      l.append([x for x in list(permutations('1379', y))])
  </code></pre>
  
  <p>How can I do a double-variable list comprehension? Thanks!</p>