M
M
maxmine22020-05-05 07:52:17
Python
maxmine2, 2020-05-05 07:52:17

Why doesn't in work in python 3?

Hello! I did a tic-tac-toe check. I have a list of lists of winning combinations. But, unfortunately, even the same combinations in does not want to compare, it always returns False

win_combos = [
                     [(0, 0), (0, 1), (0, 2)],
                     [(1, 0), (1, 1), (1, 2)],
                     [(2, 0), (2, 1), (2, 2)],
                     [(0, 0), (1, 0), (2, 0)],
                     [(0, 1), (1, 1), (2, 1)],
                     [(0, 2), (1, 2), (2, 2)],
                     [(0, 0), (1, 1), (2, 2)],
                     [(2, 0), (1, 1), (0, 2)]]
        cells = self.field.cells
        xcells = []
        ocells = []
        empty_cells = []
        for row in cells:
            for cell in row:
                if cell.object == PlayingObject.Cross:
                    xcells.append((cell.x, cell.y))
                elif cell.object == PlayingObject.Donut:
                    ocells.append((cell.x, cell.y))
                else:
                    empty_cells.append(cell)
                continue
        for combo in win_combos:
            if ocells in combo: # здесь
                self.draw()
                self.win()
            if xcells in combo: # и здесь
                self.draw()
                self.over()
        if len(empty_cells) == 0:
            self.draw()
            self.gdraw()

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question