So I build a tiny bingo program for my wife to use at her candle parties. The boards are already generated. This is just a program to call out the numbers.
import random
a = []
a = list(range(1,76))
random.shuffle(a)
def pop(x):
while 1:
b = a.pop(0)
if b <= 15:
print 'b', b,
elif b > 15 and b <=30:
print 'i', b,
elif b > 30 and b <=45:
print 'n', b,
elif b > 45 and b <=60:
print 'g', b,
else:
print 'o', b,
raw_input('')
pop(1)
Now her parties are getting larger and she is worried about someone cheating so I would like to add in a feature where I could type in the numbers that supposedly won and have the program let me know if those numbers where indeed called. I have tried running it to a file with
def pop(x):
while 1:
b = a.pop(0)
with open('bingo.txt', 'w') as file1:
file1.write(b,'\n')
if b ...
but it just opens and then closes back down. No errors or any text to the file. It doesn't need to go to a file. I just thought that if it did, I could then add in a searchfile feature at the end and know whether the number was called or not. What would be the best way to find out if the numbers on the "winning" line were actually called?