【发布时间】:2014-08-28 22:34:30
【问题描述】:
我对这段代码有疑问:
List=[' ', 'X', 'X', 'X']+[' ']*6
le='X'
def Return():
return((for i in range(1, 10, 3):
(List[i]==le and List[i+1]==le and List[i+2]==le)))
我想用 for 循环来编写它,而不必像这样指定:
def Return():
return ((List[1]==le and List[2]==le and List[3]==le) or #True
(List[4]==le and List[5]==le)...etc.)
当我使用 foo 循环时,我只收到一条消息说“无效语法”,但我不明白为什么。
【问题讨论】: