I am trying to create a loop to play a game.
I want to match if a tuple returns value as provided, the result should be confess or Don't confess. Lets call them payoff. But in the following test code it returns (0, 0) as confess which was not in the original list returns Confess.
Dont confess: (-1, -1)
Confess : (-10, 0)
Confess : (0, -10)
Dont Confess: (-10, -10)
dntCon=(-1, -1)
conf=(-10, 0)
confess=(0, -10)
DntConff=(-5, -5)
import random
from random import shuffle
from random import sample
x = [-1, -10, 0, -5]
y = [-1, 0, -10, -5]
#print(sample(list, len(list)))
for m in range(0, 3):
x=random.sample(x, len(x))
y=random.sample(y, len(y))
#print(x, y)
for i in x:
#print(i)
for j in y:
#print(i, j)
if(i ==-1 & j==-1 ):
print(i, j, "ncoo")
#print( i, j,'')
elif (i==-10 & j==0):
print(i, j, 'Confess')
elif (i==0 & j==-10):
print(i, j, 'Confess')
elif (i==-10 & j==-10):
print(i, j, 'ncoo')
else:
"not met"
Results
(0, 0, 'Confess')
(-10, -10, 'ncoo')
(-10, -1, 'ncoo')
(-1, -1, 'ncoo')
(0, 0, 'Confess')
(-10, -10, 'ncoo')
(-10, -1, 'ncoo')
(-1, -1, 'ncoo')
(-10, -1, 'ncoo')
(-10, -10, 'ncoo')
(-1, -1, 'ncoo')
(0, 0, 'Confess')
Why is this loop returning (0, 0
) as confess which does not meet my criteria