slow script trying to find unique values in list
<p>I've got a problem in Python:
I want to find how many UNIQUE <code>a**b</code> values exist if:<br>
&nbsp;&nbsp;&nbsp;&nbsp;<code>2 â¤ a â¤ 100</code>and <code>2 â¤ b â¤ 100</code>?</p>

<p>I wrote the following script, but it's too slow on my laptop (and doesnt even produce the results):</p>

<pre><code>List=[]
a = 2
b = 2
c = pow(a, b)
while b != 101:
    while a != 101:
        if List.count(c) == 0:
            List.append(c) 
            a += 1
    b += 1
print len(List)
</code></pre>

<p>Is it good? Why is it slow?</p>

<p>The reason your script is slow and doesn't return a value is that you have created an infinite loop. You need to dedent the <code>a += 1</code> line by one level, otherwise, after the first time through the inner <code>while</code> loop <code>a</code> will not get incremented again.</p>

<p>There are some additional issues with the script that have been pointed out in the comments, but this is what is responsible for the issues your are experiencing.</p>

python