Python自学:第四章 复制列表(1)

# -*- coding: GBK -*-

my_foods = ['pizza', 'falafel', 'carrot cake']
friend_foods = my_foods[:]

print("My favorite foods are:")
print(my_foods)

print("\nMy friend's favorite foods are:")
print(friend_foods)

输出为:

My favorite foods are:
['pizza', 'falafel', 'carrot cake']

My friend's favorite foods are:
['pizza', 'falafel', 'carrot cake']

 

posted @ 2019-05-20 13:55  Johnson蚂蚁  阅读(169)  评论(0编辑  收藏  举报