notdone = [tuple((x,y))for x in range(5) for y in range(6)]
for i in showns:
s = lambda :tuple(random.sample(notdone,1)) #random.sample gives a LIST even though I used tuple()
print notdone #debug
a = s()
print a #debug
notdone.remove(a)
b = s()
flashcards[a] = Flashcard((x*20,y*100),i)
flashcards[b] = Flashcard((x*20,y*100),i)
[(0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (1, 0), (1, 1), (1, 2), (1, 3),
(1, 4), (1, 5), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (3, 0), (3, 1),
(3, 2), (3, 3), (3, 4), (3, 5), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5)]
((4, 0),)
Traceback (most recent call last):
File "C:\Users\William\Desktop\memory.py", line 51, in <module>
notdone.remove(a)
ValueError: list.remove(x): x not in list
I think it's because tuples are immutable, so their diffrent objects with the same value.
You see, (4,0)
is in notdone
.Why tuples?Because you can't hash a list. I'm using x,y coordinates so I can track it.