title: Find all words with a given length in Python
body: <p>I want to make a function that finds all words with a given length, but I can't make it using <code>re.findall</code>, because it only works with integers.</p>
  
  <p>This doesn't seem to be working:</p>
  
  <pre><code>f = open("wordlist.txt", "r")
  line = f.readlines()
  a = 14
  k = re.findall(r'\b[a-zA-Z]{a}\b', ' '.join(line))
  r = random.choice(k)
  </code></pre>
  
  <p>Neither this:</p>
  
  <pre><code>d = input()
  k = re.findall(r'\b[a-zA-Z]{d}\b', ' '.join(line))
  r = random.choice(k)
  </code></pre>
  
  <p>Both gives:
  <strong>IndexError: Cannot choose from an empty sequence</strong></p>
  
  <p>What could I do?</p>