pythOn for循环

pythOn for循环

  • for animal in animals:
  •   print(animal)
    注意两点一个是注意加冒号;一个是只有命令行前面有空格才能执行循环(不管几个空格)

例题4-2

animals = ['pig','dog','cat']
for animal in animals:
    print('A ' + animal + "would make a great pet")
print('Any of these animals would make a great pet!')

posted @ 2020-07-16 11:19  无涯987  阅读(114)  评论(0)    收藏  举报