简介
"Python 三剑客"之一,豆瓣评分 9.3;另外两剑客为 《Python 编程快速上手 —— 让繁琐 工作自动化》和《Python 极客项目编程》第二版
- 书名:《Python 编程:从入门到实践》
- 作者:[美]埃里克·马瑟斯
- 时间:2023-05-01
- 出版社:人民邮电出版社
第一部分 基础知识
第 1 章 起步
第 2 章 变量和简单的数据类型
第 3 章 列表简介
第 4 章 操作列表
4.1 遍历整个列表
for 循环语法
for item in items:
operation_1
operation_2
...
operation_n
冒号后面的每一行缩进语句都是 for 循环每次执行的代码
使用循环打印魔术师的名字
magicians.py
magicians = ["alice", "david", "carolina"]
for magician in magicians:
print(f"{magician.title()}, that was a great trick!.")
print(f"I cat't wait to see your next trick, {magician.title()}\n")