pythOn for循环
时间:2020-07-16 12:19:24
收藏:0
阅读:59
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!‘)
评论(0)