# -*- coding:utf-8 -*-# Author:sweeping-monk# -*-操做列表-*-Traverse_the_list = ['guanfu','xiaole','fangdong','rourou']for name in Traverse_the_list: #经过for循环将列表中的元素都一个一个的打印出来。 print(name)#magicians = ['alice','david','carolina'] #练习for循环。#for magician in magicians:# print(magician.title() + ",that was a great trick!") #这一行必须缩进,不然报错。# print("I can't wait to see your next trick, " + magician.title() + ".\n") #要想让for循环执行,就必须在for循环后面缩进。magicians = ['alice','david','carolina'] #练习for循环。for magician in magicians: print(magician.title() + ",that was a great trick!")print("I can't wait to see your next trick, " + magician.title() + ".\n") #这是没缩进后的效果。Chicken_soup = '''python根据缩进来判断代码行与前一个代码行的关系,缩进让代码整洁而结构清晰。'''print(Chicken_soup)Common_mistakes = "常见的缩进错误举例:\n"print(Common_mistakes)#magicians = ['alice','david','carolina']#for magician in magicians:#print(magician.title() + ",that was a great trick!") #应缩进却没缩进,python会提醒你。magicians = ['alice','david','carolina']for magician in magicians: print(magician.title() + ",that was a great trick!")print("I can't wait to see your next trick, " + magician.title() + ".\n") #这一条没有缩进,所以它只能循环结束后执行一次。#这是一个逻辑错误。从语法上看是合法的。#msg = "lao si ji"# print(msg) #不必的缩进。#Traverse_the_list = ['guanfu','xiaole','fangdong','rourou']#for name in Traverse_the_list #for语句后面的冒号告诉python,下一话是循环的第一行。这里漏掉了冒号致使语法错误。# print(name)