title: How to get percentage of combinations computed?
body: <p>I have this password generator, which comute combination with length of 2 to 6 characters from a list containing small letters, capital letters and numbers (without 0) - together 61 characters.</p>
  
  <p>All I need is to show percentage (with a step of 5) of the combinations already created. I tried to compute all the combinations of selected length, from that number a boundary value (the 5 % step values) and count each combination written in text file and when when the count of combinations meets the boundary value, print the <code>xxx % completed</code>, but this code doesn't seem to work.</p>
  
  <p>Do you know how to easily show the percentage please?</p>
  
  <p>Sorry for my english, I'm not a native speaker.</p>
  
  <p>Thank you all! </p>
  
  <pre><code>def pw_gen(characters, length):
  
      """generate all characters combinations with selected length and export them to a text file"""
  
      # counting number of combinations according to a formula in documentation
      k = length
      n = len(characters) + k - 1
      comb_numb = math.factorial(n)/(math.factorial(n-length)*math.factorial(length))
  
      x = 0
  
      # first value
      percent = 5
  
      # step of percent done to display
      step = 5
  
      # 'step' % of combinations
      boundary_value = comb_numb/(100/step)
  
      try:
          # output text file
          with open("password_combinations.txt", "a+") as f:
              for p in itertools.product(characters, repeat=length):
                  combination = ''.join(p)
  
                  # write each combination and create a new line
                  f.write(combination + '\n')
                  x += 1
  
                  if boundary_value &lt;= x &lt;= comb_numb:
                      print("{} % complete".format(percent))
                      percent += step
                      boundary_value += comb_numb/(100/step)
  
                  elif x &gt; comb_numb:
                      break
  </code></pre>