码迷,mamicode.com
首页 > 编程语言 > 详细

python中For循环

时间:2016-01-21 20:11:39      阅读:184      评论:0      收藏:0      [点我收藏+]

标签:python中for循环

打印出1到100的数,不包含100

for i in range(1,100):

if i==23:

print "great,you got your luncky number:",i

print ‘The unmber is:‘,i

================23会被重复打印===============================



for i in range(1,100):

    if i==23:

           print "great,you got your luncky number:",i

    else:

           print "The unmber is:",i

================23只会打印一次===============================



for i in range(1,100):

if i==23:

print "great,%s lucky number:"%i  #%s,引用外部的变量;外部的变量则为:引号之外的变量

print "The number is:",i


python中For循环

标签:python中for循环

原文地址:http://11143863.blog.51cto.com/11133863/1737316

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!