Python入门习题大全——索引
创建两个比萨列表,通过 for 循环打印各个列表。
# 你的比萨和我的比萨
pizzas = ['A', 'B', 'C']
friend_pizzas = pizzas[:]
pizzas.append('D')
friend_pizzas.append('E')
print("My favorite pizzas are:")
for pizza in pizzas:
print(pizza)
print("My friend's pizzas are:")
for pizza in friend_pizzas:
print(pizza)
输出为:
My favorite pizzas are:
A
B
C
D
My friend's pizzas are:
A
B
C
E