📜  python for else - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:59.281000             🧑  作者: Mango

代码示例1
for n in range(2, 10):
    for x in range(2, n):
        if n % x == 0:
            print( n, 'equals', x, '*', n/x)
            break
    else:
        # loop fell through without finding a factor
        print(n, 'is a prime number')