python验证37的倍数

上面是我写的代码下面是原问题,跑不出来,麻烦大家帮我看看问题在哪里,谢谢大家!!

img

img

1、while循环没必要,会一直死循环;
2、计算个位、十位、百位的方式不对
修改后的代码:

for i in range(100, 1000):
    bai = i // 100
    shi =  i // 10 % 10
    ge = i % 100 % 10
    # print(i, bai, shi, ge)
    if i % 37 == 0 and (ge * 100 + bai * 10 + shi) % 37 == 0 \
        and (shi * 100 + ge * 10 + bai) % 37 == 0:
        print("【%s】:This is a true proposition" % i)
    else:
        print("This is a false proposition")

有帮助的话,请点采纳该答案~