|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- >>> magicians =['alice','ben','peter']
- >>> for magician in magicians :
- print(magician.title()+",that was a great trick!")
- print("i can not wait to see your next trick,"+magician.title()+".\n")
-
- print(thank you,everyone.that was a great magic show!)
复制代码
这个运行到最后报错:SyntaxError: invalid syntax
下图是书上的案例:
本帖最后由 醉酒青牛 于 2017-9-13 13:46 编辑
for循环并没有问题,问题是最后一句print语句,你应该是想打印一句字符串,可是你没有加引号,仅此而已。
- magicians =['alice','ben','peter']
- for magician in magicians:
- print(magician.title()+",that was a great trick!")
- print("i can not wait to see your next trick,"+magician.title()+".\n")
- print('thank you,everyone.that was a great magic show!')
复制代码
|
|