lundi 30 janvier 2017

If 'X' and 'O' not in string, then: [duplicate]

This question already has an answer here:

While studying to a test, I got this problem that I could not solve. I was doing a program that analyses a list of strings of three characters, '.', 'X', and 'O'. The program had to interpret the combinations of these strings and return the number of columns, lines or diagonals in which it was still possible to fill with 'X' or 'O' (tic-tac-toe game). So I wanted to make a condition which is verbally like this:

If both 'X' and 'O' are not in the string, then...

So I wrote :

if ('X' and 'O') not in string:
    count = count + 1

But it the condition is false if the string is '..O', and I don't understand why.

Aucun commentaire:

Enregistrer un commentaire