Im just starting out with my python learning, and having reached my first capstone project (tik_tak_toe) using jupyter notebook, I wondered if there was a cleaner and/more efficient way of running my check to determine a winner. Just to fully clarify for context:
-"board" in a numeric pattern similar to that on a full sized keyboard (top = 7,8,9 middle = 4,5,6 etc)
the board is created in a dictionary, with keys 1-9
key values are altered by (user = int(input('number')), then board[user] = 'X' / 'Y'
def result_check(test): # VERTICAL WIN_CHECK if ('X' in test[1] and test[2] and test[3]) : return True elif ('Y' in test[1] and test[2] and test[3]): return elif ('X' in test[4] and test[5] and test[6]): return True elif ('Y' in test[4] and test[5] and test[6]): return True elif ('X' in test[7] and test[8] and test[9]) : return True elif ('Y' in test[7] and test[8] and test[9]): return True # HORIZONTAL WIN _CHECK elif ('X' in test[7] and test[4] and test[1]): return True elif ('Y' in test[7] and test[4] and test[1]): return True elif ('X' in test[8] and test[5] and test[2]): return True elif ('Y' in test[8] and test[5] and test[2]): return True elif ('X' in test[9] and test[6] and test[3]): return True elif ('Y' in test[9] and test[6] and test[3]): return True # DIAGONAL WIN_CHECK elif ('X' in test[7] and test[5] and test[3]): return True elif ('Y' in test[7] and test[5] and test[3]): return True elif ('X' in test[9] and test[5] and test[1]): return True elif ('Y' in test[9] and test[5] and test[1]): return true else: return False