需要一些援助:
我在OR操作数方面遇到了一些问题…我理解它是如何工作的(OR条件必须为true),但我不确定它为什么会以下面解释的方式运行
“or”语句似乎没有检查“FlowControl”函数中的第二个条件。。当我输入“y”时,它会看到条件为真,并且运行时没有任何问题。。。但是,当我输入“是”时,它会将条件评估为false
-我排除了其他功能-
def flowControl():
answer = input("do you want run the 'displayLession' function? ( yes or
no)").strip()
if answer == ('y' or 'yes'):
displayLesson()
else:
userTime()
print('End program')
流量控制()
你要找的是
或
为什么??很简单,您的代码在括号
'y' or 'yes'
之前求值,这是'y'
,因为'y'
在python中是一个真实的表达式,所以无需对后一个表达式求值相关问题 更多 >
编程相关推荐