有趣的python警长

1.问题描述:

请用python实现推断小偷是谁?


2.上代码:

for thief in ["a", "b", "c", "d"]:
    sum = (thief != "a") + (thief == "c") + (thief == "d") + (thief != "d")
    if sum == 3:

        print((thief != "a"))
        print((thief != "a")+(thief == "c"))
        print((thief != "a")+(thief == "c")+ (thief == "d"))
        print("小偷是:%s" % thief)

3,执行结果:


猜你喜欢

转载自blog.csdn.net/liangkaiping0525/article/details/80862447