一道逻辑推理题 请问我的错误在哪里?

img


为什么正确答案和我的程序得出的答案不同?是哪里错了,求指教。

没必要这么麻烦,遍历一遍就行

img

for iNum in['甲','乙','丙','丁']:
    if(iNum=='丙' or iNum=='丁')+(iNum=='丁')+(iNum!='丙')+(iNum!='丁')==3:
        print(iNum,"打碎玻璃")


def testCase(x):
    a=(x==3 or x==4)
    b=(x==4)
    c=not(x==3)
    d=not(x==4)

    if(not a and b and c and d) or \
    (not b and a and c and d) or \
    (not c and a and b and d) or \
    (not d and a and b and c):
        return True
    return False

def findIt():
        for x in range(1,5):
            if(testCase(x)):
                return x
        return -1

name = ['甲','乙','丙','丁']
x=findIt()
if(x>=1):
    print('这人是%s'%(name[x-1]))
else:
    print('无法判断')

把代码放到代码块里发一下,
图片没办法本地跑看原因