python基础知识(循环语句)

for循环、while循环、循环嵌套

for 迭代变量 In 对象:

  循环体

range(start,end,step) 第一个和第三个可以省略生成一系列的连续整数

start 包括起始值

end  不包括结束值

step 步长

while循环

while 条件表达式:

  循环体

跳转语句

break语句  跳出循环结束语句

continue语句   只跳出一次循环

total = 99

for number in range(1,100):

  if number % 7 == 0:

    continue

  else:

    string = str(number)

    if string.endswith('7')      #判断是否以7结尾

      continue

  total -= 1

print("从1数到99共拍桌子",total,"次")

原文地址:https://www.cnblogs.com/zhangjiantaocs/p/11837634.html