Two separate lists with corresponding numbers. How to detect them remove them from the list?
<p>I'm looking to create a program which randomly generates coins on an 8x8 grid.  I've got two lists being created (one list for the X co-ordinate and list for the Y co-ordinate).  On these lists, the two co-ordinates cannot be the same.  It's difficult to explain, so here's what I mean by example:</p>

<pre><code>[1, 7, 4, **6**, 9, 2, 3, **6**, 8, 0] (list for the x co-ordinate)
[9, 3, 3, **1**, 2, 8, 0, **1**, 6, 1] (list for the y co-ordinate)
</code></pre>

<p>So, two lists are created. However <code>(6,1)</code> appears twice.  I don't want this.  So, how would I allow for this in my code, to ensure that this is ignored and the numbers are regenerated into different co-ordinates?  The code I have is below, I don't really know how to implement such a system thing!  </p>

<pre><code>def treasurePro():
    global coinListX, coinListY
    coinListX = []
    coinListY = [] 
    for x in range(10): 
        num = randint(0,8) 
        coinListX.append(num) 
        print(coinListX)
    for x in range(10): 
        num = randint(0,8)
        if num == 0 and coinListX[x] == 0:
            treasurePro() #goes back to the beginning to restart.  
        else:
            coinListY.append(num) 
            print(coinListY)
</code></pre>

<p>You want to generate random coordinates, but you also want to reject any
pair of coordinates that already appears in the list. (Incidentally,
instead of two separate lists of integers, I would suggest using one
list of ordered pairs, i.e., tuples of two integers.)</p>

<p>One way to reject duplicates would be to search the existing list for
the new set. This is O(n) and slower than it needs to be, though it
would certainly work in your use case where n can't exceed 64.</p>

<p>Another way would be to maintain a second data structure where you can
look up each of the 64 cells in O(1) time, such as an 8x8 array of
booleans. Indeed, you could use this one structure by itself; to get a
list of the coordinates used, just traverse it.</p>

python arrays list python-3.x