colors =["yellow","blue","orange","purple"]//定义列表
for color in colors://从列表colors取出一个颜色,并将其存在变量color中
print(color)print("These colors are all my favorite colors")//为for循环外的代码块,在for循环结束后执行
//输出结果为:
yellow
blue
orange
purple
These colors are all my favorite colors
使用for循环遍历整个列表信息colors = ["yellow", "blue", "orange", "purple"] //定义列表for color in colors: //从列表colors取出一个颜色,并将其存在变量color中 print(color)print("These colors are all my favorite colors") //为for循环外...