Print(f"\nNumber drawn: įor idx, key in zip(reversed(range(3)), d):Īlso, the return True on all of the conditions means that the function will stop once a winning condition is hit, rather than going through all of the conditions when you really don't need to. Number_drawn = draw(card, random_draw_list) While win = False and user_input != "quit": Print("\nKeep pressing enter to continue or type quit to exit.\n") ![]() Generates a card, prints it, and loops through drawingĪnd printing until the check_win method returns True or the user enters "quit". If card = "X" and card = "X" and card = "X" and card = "X" and card = "X":Įlif card = "X" and card = "X" and card = "X" and card = "X" and card = "X":Įlif card = "X" and card = "X" and card = "X" and card = "X": List (list): The list of random numbers to be drawn from.įirst checks for diagonal wins, then four-corner, then horizontal, and finally, vertical.Ĭard (dictionary): The card to check for a win. ![]() Using the pop method ensures no duplicateĬard (dictionary): The card to to check for the number that was drawn. Pops a number off a list of random numbers. Generates a bingo card and stores the numbers in a dictionary.Ĭard = random.sample(range(min, max), 5)Ĭard (dictionary): The card to be printed out. Random_draw_list = random.sample(range(1, 76), 75) I went above and beyond what the assignment called for so I need a little more helping making sure the code is okay. This is for a class, and my professor is a stickler for using best practices. ![]() I am posting it here to make get some help reviewing it to make sure I'm using the best practices. I am super proud of this python bingo game I wrote.
0 Comments
Leave a Reply. |