返回顶部

收藏

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

»更多 您可能感兴趣的代码
  1. 2012-11-05 21:59:42java获得随机数代码 by 怪兽狂殴奥特曼
  2. 2014-08-18 14:05:14Softmax Regression by xwz
  3. 2014-08-26 11:44:11查单词的脚本 by 风云轩
  4. 2014-09-02 13:16:29Python Generators 用法 by 阮小七
  5. 2014-09-14 16:57:09元类 metaclass by jack.chen
  6. 2014-09-19 13:25:44Levenshtein字符串相似度 by xwz
  7. 2014-09-24 15:54:45IP地址与Bigint转换 by 蟋蟀MM
  8. 2014-11-04 15:08:25Python的logging模块封装 by 山药
  9. 2014-11-14 14:28:06Python ConfigParser模块 by xwz
  10. 2014-12-02 12:44:30创建一个简单的电话本,支持添加和查询功能 by Solon.Ring
  11. 2015-11-25 09:04:20Mixed String type: normal string and unicode by 张宋付

发表评论