The point of this game is to have two people flip a coin, and if the first person gets heads and the second person gets heads, the first person wins, but if the second person gets the opposite coin they win. My code's output just displays "True" a thousand times, but I have a for loop in my method that isn't working?
import numpy as np
class Students():
def __init__(self,flip,history):
self.flip=flip
self.history=history
def flipcoin(self):
for self.flip in range (0,1000):
self.flip= np.random.random()
if (self.flip<0.5):
self.flip=0
else:
self.flip=1
print (str(self.flip))
self.history= self.flip
print(self.history)
return (str(self.flip))
student1=Students(flip=0,history=[])
student1.flipcoin()
student2=Students(flip=0,history=[])
student2.flipcoin()
for Students in range (0,1000):
if (student1==student2):
print('False')
else:
print('True')
print(student1.flip,student1.history)