Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This code is pretty confused ;-) For example, you have <code>n = 0</code> in your inner loop, but never set <code>n</code> to anything else. For another, you have <code>x = 0</code>, but never use <code>x</code>. Etc.</p> <p>Using <code>itertools</code> is really best, but if you're trying to learn how to do these things yourself, that's fine. For a start, change your:</p> <pre><code> letters = list(letternums) </code></pre> <p>to</p> <pre><code> letters = list(letternums) print(letters) break </code></pre> <p>I bet you'll be surprised at what you see! The elements of your <code>combolist</code> are tuples, so when you do <code>letternums = str(i)</code> you get a string with a mix of digits, spaces, parentheses and commas. I don't think you're <strong>expecting</strong> anything but digits.</p> <p>Your <code>letterstwo</code> is the string "1" (always, because you never change <code>n</code>). But it doesn't much matter, because you set <code>hits</code> and <code>nonhits</code> to 0 <strong>every</strong> time your <code>for g in letters</code> loop iterates. So <code>hits</code> and <code>nonhits</code> can never be bigger than 1.</p> <p>Which answers your literal question ;-) <code>combolisttwo.append(i)</code> is never executed because <code>hits + nonhits == 4</code> is never true. That's why <code>combolisttwo</code> remains at its initial value (<code>[1]</code>).</p> <p>Put some calls to <code>print()</code> in your code? That will help you see what's going wrong.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload