Stuck in a loop

Terry Reedy tjreedy at udel.edu
Tue Apr 1 01:20:19 EDT 2008


<hexusnexus at gmail.com> wrote in message 
news:e131eb4b-7e78-41b2-8bfd-d7619d620f85 at c26g2000prf.googlegroups.com...
|I wrote a simple algorithm and it keeps getting stuck in a loop.  I
| guess I'm just to tired to figure it out:

The easiest way to figure out somethinglike this is to print your variables
from inside the loop to see things stick, or if there is a cycle.

| compcount=[5,4,2,2]
| suitrank=[0,0,0,0]
|
| trump=2
| l,lt=0,0
| while l<4:
|    while lt<4:

print l, lt

|        if l==trump:
|            l+=1
|        if l>3:
|            break
|        if lt==trump:
|            lt+=1
|        if compcount[l]<compcount[lt]:
|            suitrank[l]+=1
|    lt+=1
| l+=1






More information about the Python-list mailing list