# -*- 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']

Python自学:第四章 复制列表(1)的更多相关文章

  1. Python自学:第四章 切片

    # -*- coding: GBK -*- players = ['charles', 'martina', 'michael', 'florence', 'eli'] print(players[0 ...

  2. Python自学:第三章 确定列表长度

    >>> cars = ["bmw", "audi", "toyota", "subaru"] > ...

  3. Python自学:第三章 在列表末尾添加元素与在列表中插入元素

    motorcycles = ['honda', 'yamaha' ,'suzuki'] motorcycles.insert(0, "ducati") print(motorcyc ...

  4. Python自学:第三章 修改列表元素

    motorcycles = ['honda', 'yamaha', 'suzuki'] print(motorcycles) motorcycles[0] = 'ducati' print(motor ...

  5. Python自学:第三章 使用列表中的各个值

    bicycles = ['trek','cannondale','redline','specialized'] message = "My first bicycle was a &quo ...

  6. Python自学:第三章 访问列表元素

    #输出并首字母大写 bicycles = ['trek','cannondale','redline','specialized'] print(bicycles[0].title()) 输出为: T ...

  7. Python自学:第四章 遍历切片

    # -*- coding: GBK -*- players = ['charles', 'martina', 'michael', 'florence', 'eli'] print("Her ...

  8. Python自学:第四章 在for循环结束后执行一些操作

    # -*- coding: GBK -*- magicians = ['alice', 'david', 'carolina'] for magician in magicians: print(ma ...

  9. Python自学:第四章 在for循环中执行更多操作(2)

    # -*- coding: GBK -*- magicians = ['alice', 'david', 'carolina'] for magician in magicians: print(ma ...

随机推荐

  1. 消费kafka的消息,并将其SparkStreaming结果保存到mysql

    将数据保存到mysql,需要用到jdbc.为了提高保存速度,我写了一个连接池 1.保存到mysql的代码 package test05 import org.apache.log4j.{Level, ...

  2. 【转载】vue install报错run `npm audit fix` to fix them, or `npm audit` for details html

    原链接https://www.jianshu.com/p/60591cfc6952 执行npm install 出现如下提醒 added 253 packages from 162 contribut ...

  3. sort -n

    输入如下测试数据:  当按照第一列排列时是正确的:  但按照第二列排序时,喵喵喵???怎么跟说好的不一样啊!!!为什么gugu的50会排在最后?  其实是因为默认是按照第二列的第一个字符来比较的,若想 ...

  4. 【LeetCode】Heap

    [215] Kth Largest Element in an Array [Medium] 给个无序数组,返回第K大的数字. 方法1. 直接使用优先队列 priority_queue class S ...

  5. java笔试题大全之IO流常见选择题

    1.下面哪个流类属于面向字符的输入流()选择一项)A. BufferedWriterB. FileInputStreamC. ObjectInputStreamD. InputStreamReader ...

  6. Yii2 数据库Active Record(ORM)

    ACTIVE RECORD(ORM) 参考:http://www.yiiframework.com/doc-2.0/guide-db-active-record.html namespace app\ ...

  7. sql INSERT语句

    当我们需要向数据库表中插入一条新记录时,就必须使用INSERT语句. INSERT语句的基本语法是: INSERT INTO <表名> (字段1, 字段2, ...) VALUES (值1 ...

  8. APICloud框架--sublime使用自定义loader

    官方的apploader调试器,只是有官方的一些模块,如果我们使用非官方的模块就要使用自定义loader进行调试.接下来就走一边sublime设置自定义loader的步骤 修改config.xml 打 ...

  9. 树形dp+贪心+增量法+排序——cf1241E(好题)

    /* 给定一棵树,每个结点最多选和其相连的k条边,问使边权和最大的策略 dp[u][0|1]用来表示u没连父边|连了父边 时u子树下的最优解 如果u不和任意一个儿子连边,那么u下的收益是tot=sum ...

  10. 吉首大学校赛 A SARS病毒 (欧拉降幂)

    链接:https://ac.nowcoder.com/acm/contest/925/A来源:牛客网 题目描述 目前,SARS 病毒的研究在世界范围内进行,经科学家研究发现,该病毒及其变种的 DNA ...