Trying to find what is wrong with my code

  python-3.x

I am a beginner at python and trying to develop a TicTacToe game of my own.
I have created a dictionary for the game table and a variable to check for Win.
Here is the code..

Board = {'1':'1','2':'6','3':'7',
         '4':'2','5':'5','6':'8',
         '7':'3','8':'4','9':'9'}

Win = Board['1'] == Board['2']== Board['3']=='X' or Board['4'] == Board['5'] == Board['6'] or Board['7'] == Board['8'] == Board['9'] or Board['1'] == Board['5'] == Board['9'] or Board['3'] == Board['5'] == Board['7'] or Board['1'] == Board['4'] == Board['7'] or Board['2'] == Board['5'] == Board['8'] or Board['3'] == Board['6'] == Board['9'] 
turn = 'X'
print(Win)

for i in range(9):
    a = str(input('Enter choice {}: '.format(turn)))
    Board[a] = turn
    turn = 'Y' if turn == 'X' else 'X' 
    if Win:   *#Here I am expecting Win to be True but it is actually False*
        print('Win')

The variable ‘win’ is not changing from false to true
Please help me out with this.

Source: Python-3x Questions

LEAVE A COMMENT