when you use break jump out from for or while statement,if has else caluse,it will not exec,
for example:
>>> for i in xrange(0,11):
    print i
else:
    print "haha,%s"%i

   
0
1
2
3
4
5
6
7
8
9
10
haha,10
>>> for i in xrange(0,11):
    print i
    if i>7:
        print "jump"
        break
else:
    print "haha,%s"%i

   
0
1
2
3
4
5
6
7
8
jump
>>>


python for ,loop ,else condition test

相关文章:

  • 2021-11-27
  • 2022-02-07
  • 2021-06-17
  • 2022-12-23
  • 2022-12-23
  • 2021-10-19
  • 2021-11-01
  • 2021-08-21
猜你喜欢
  • 2022-12-23
  • 2021-06-04
  • 2022-12-23
  • 2019-11-02
  • 2022-01-30
相关资源
相似解决方案