The problem is your conjunction: you failed to apply DeMorgan's laws properly. You need to flip from or
to and
when you distribute the negation.
not(test == 'O' or test == 'X')
is equivalent to
test!= 'O' and test!= 'X'
Look at the logic of test!= 'O' or test!= 'X'
: no matter what character you give to test
, it will be not equal to at least one of the two test characters. F0r O
, the second clause is True
; for X
, the first is True
; for any other character, both clauses are True
. To get past this, you'd need a character that was X
and O
at the same time.
We're not doing quantum variables in Python ... not yet, at least. You'd have to write a new class with custom equality operators to make this work.