straightrunfaces = 'A23456789TJQKA';
for i in range(0,10):
if ((counts[straightrunfaces[i]] and
counts[straightrunfaces[i+1]] and
counts[straightrunfaces[i+2]] and
counts[straightrunfaces[i+3]])) or
((counts[straightrunfaces[i+1]] and
counts[straightrunfaces[i+2]] and
counts[straightrunfaces[i+3]] and
counts[straightrunfaces[i+4]])):
C:\datasci_course_materials\assignment3>python poker.py
File "poker.py", line 62
counts[straightrunfaces[i+3]])) or
^
**SyntaxError: invalid syntax**
我不明白为什么“或”接线员不工作
尝试:
问题不是
or
,而是结尾的换行。不再有左括号,因此换行符终止if
语句;但是,对于解析器,if
语句必须以冒号结尾,而您的则不是。在或者添加一个显式的行延续:
或者用括号括起来:
^{pr2}$PEP 8推荐后者。在
相关问题 更多 >
编程相关推荐