Python:查找列表中是否有一组数字

时间:2017-04-08 13:03:24

标签: python python-2.7

我正在尝试制作Tic Tac Toe游戏,我想检测玩家是否赢得了比赛:

Player1Play = int(raw_input("Please choose a square: \n"))
P1Squares.append(Player1Play)
if [1,2,3] or [4,5,6] or [7,8,9] in P1Squares:
    Player1 = "WIN"
elif [1,4,7] or [2,5,8] or [3,6,9] in P1Squares:
    Player1 = "WIN"
elif [1,5,9] or [3,5,7] in P1Squares:
    Player1 = "WIN"

我认为这样可行,但是:

P1Squares = [1]

Python告诉我if语句是True并返回:

PLayer1 = "WIN"

0 个答案:

没有答案