首页 > 编程语言 > 详细

Python学习-else循环子句

时间:2018-01-21 21:17:08      阅读:204      评论:0      收藏:0      [点我收藏+]
from math import sqrt

for n in range(99, 82, -1):
    root = sqrt(n)
    if root == int(root):
        print(n)
        break
else: #发现这个else只有在break不执行的时候执行。这个是循环的else子句
    print("Didn‘t find the number!")

 

Python学习-else循环子句

原文:https://www.cnblogs.com/Ian-learning/p/8325373.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!