返回顶部

收藏

Break and continue Statements, and else Clauses on Loops

更多
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'

标签:Python,基础

收藏

0人收藏

支持

0

反对

0

发表评论