Python traverse the entire list

Use a for loop to traverse the entire list information

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
Released five original articles · won praise 0 · Views 51

Guess you like

Origin blog.csdn.net/AlwaysSpring/article/details/104550535