map = [["*","*","*"],["*","*","*"],["*","*","*"]] def ShowMap(list): print(" 1 2 3") row = 1 for wiersz in list: print(row, end=" ") for element in wiersz: print(element, end=" ") print() row += 1 def Winner(list): for x in range(0,3): if map[x][0] == map[x][1] and map[x][1] == map[x][2] and (map[x][2] == "X" or map[x][2] == "O"): return True for y in range(0,3): if map[0][x] == map[1][x] and map[1][x] == map[2][x] and (map[2][x] == "X" or map[2][x] == "O"): return True if map[0][0] == map[1][1] and map[1][1] == map[2][2] and (map[2][2] == "X" or map[2][2] == "O"): return True if map[0][2] == map[1][1] and map[1][1] == map[2][0] and (map[2][0] == "X" or map[2][0] == "O"): return True return False def Draw(list): if not Winner(list): for wiersz in list: for element in wiersz: if element == "*": return False return True else: return False cross_play = False begin = input("Jezeli ma zaczac krzyzyk wpisz X, jeżeli kółko wpisz O: ") if begin == "X" or begin == "X": cross_play = True while(not Draw(map) and not Winner(map)): ShowMap(map) x, y = [int(x) for x in input("Podaj wspolrzedne, gdzie chcesz postawic znak:").split()] if map[x-1][y-1] == "*": if cross_play: map[x-1][y-1] = "X" cross_play = False else: map[x-1][y-1] = "O" cross_play = True if Winner(map): if cross_play: ShowMap(map) print("Kolko wygralo!") else: ShowMap(map) print("Krzyzyk wygral!") else: ShowMap(map) print("Mamy remis!")