Beginner Tic-Tac-Toe in Python def draw_board(board):
    display_board = ''

    for number in list(range(len(board))):
        if (number + 1) % 3 == 0:
            if number &lt; 6:
                display_board += '  ' + str(board[number]) + '  \n—————————————————\n'
            else:
                display_board += '  ' + str(board[number]) + '  '
        else:
            display_board += '  ' + str(board[number]) + '  |'

    return display_board


def check_win(board, letter):
    if all(item == letter for item in board[:3]):
        return True
    elif all(item == letter for item in board[3:6]):
        return True
    elif all(item == letter for item in board[6:9]):
        return True
    elif all(item == letter for item in board[::3]):
        return True
    elif all(item == letter for item in board[1::3]):
        return True
    elif all(item == letter for item in board[2::3]):
        return True
    elif all(item == letter for item in board[::4]):
        return True
    elif all(item == letter for item in board[2:8:2]):
        return True


x = input('Who is X?  &gt; ')
o = input('Who is O?  &gt; ')

squares = {
    'nw': 0, 'n': 1, 'ne': 2,
    'w': 3, 'c': 4, 'e': 5,
    'sw': 6, 's': 7, 'se': 8
}

directions = list(squares.keys())

tic_tac_toe_board = [
    '.', '.', '.',
    '.', '.', '.',
    '.', '.', '.'
]

valid_turns = 0
x_turn = True
print(draw_board(tic_tac_toe_board) + '\n(Xs first) ', end='')

while valid_turns &lt; 9:
    square = input('Exactly type in the following available directions: ' + ', '.join(directions) + '  &gt; ')

    if square.lower() in directions:
        directions.remove(square.lower())

        if x_turn:
            tic_tac_toe_board[squares[square.lower()]] = 'X'
            x_turn = False
        else:
            tic_tac_toe_board[squares[square.lower()]] = 'O'
            x_turn = True

        valid_turns += 1
    else:
        print('INVALID MOVE')

    print(draw_board(tic_tac_toe_board))

    if check_win(tic_tac_toe_board, 'X'):
        print(x + ' has won!')
        break
    elif check_win(tic_tac_toe_board, 'O'):
        print(o + ' has won!')
        break

if valid_turns == 9:
    print('DRAW!')
Ways of improving/optimizing:


draw_board function.


prefer enumerate(board) over redundant list(range(len(board)))
all conditional branches within for loop have the same common expression to append '  ' + str(board[number]) + '  '. Thus, it can be moved up to reduce conditional branches
prefer flexible f-string formatting over awkward string concatenation combined with casting to str



Now the optimized draw_board function would look as:

def draw_board(board):
    display_board = ''

    for i, v in enumerate(board):
        display_board += f'  {v}  '
        if (i + 1) % 3 == 0:
            if i &lt; 6:
                display_board += '\n—————————————————\n'
        else:
            display_board += '|'

    return display_board

check_win function introduces many repetitive checks all(item == letter for item in board[...]) with the same returned value.
A more flexible way is to create an additional function to check crossed row:

def row_crossed(letter, row):
    return all(item == letter for item in row)


Then, check_win would call any function on generator expression that yields all the needed sub-checks:

def check_win(board, letter):
    return any((row_crossed(letter, board[:3]), row_crossed(letter, board[3:6]),
            row_crossed(letter, board[6:9]), row_crossed(letter, board[::3]),
            row_crossed(letter, board[1::3]), row_crossed(letter, board[2::3]),
            row_crossed(letter, board[::4]), row_crossed(letter, board[2:8:2])))

square dictionary. To reduce quotes mess it can be composed in concise way with zip and range functions:

squares = dict(zip(('nw', 'n', 'ne', 'w', 'c', 'e', 'sw', 's', 'se'), range(9)))

tic_tac_toe_board easily replaced with tic_tac_toe_board = ['.'] * 9 
square.lower() repeats 4 times within main while loop. Instead, extract that expression into a variable at once and refer it:

square = input('Exactly type in the following available directions: {}  &gt; '.format(', '.join(directions)))
square = square.lower()

the whole condition:

if x_turn:
    tic_tac_toe_board[squares[square.lower()]] = 'X'
    x_turn = False
else:
    tic_tac_toe_board[squares[square.lower()]] = 'O'
    x_turn = True


would be simplified as it relies on explicit negation of x_turn flag.Getting  2 lines against 6:

tic_tac_toe_board[squares[square]] = 'X' if x_turn else 'O'
x_turn = not x_turn