motorcycle = ["honda", "yamaha", "suzuki"]

last_owned = motorcycle.pop()
print("The last motorcycle I owned was a " + last_owned.title() + ".")

输出为:

The last motorcycle I owned was a Suzuki.

Python自学:第三章 使用方法pop()删除元素的更多相关文章

  1. Python自学:第三章 使用del语句删除元素

    motorcycles = ["honda", "yamaha", "suzuki"] print(motorcycles) del mot ...

  2. Python自学:第三章 使用方法sort( )对列表进行永久性排序

    cars = ["bmw", "audi", "toyota", "subaru"] cars.sort() print ...

  3. Python自学:第三章 弹出列表中任何位置处的元素

    motorcycles = ["honda", "yamaha", "suzuki"] first_owned = motorcycles. ...

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

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

  5. Python自学:第三章 倒着打印列表

    # -*- coding: GBK -*- #reverse: 相反的 cars = ["bmw", "audi", "toyota", & ...

  6. Python自学:第三章 使用函数sort( )对列表进行临时排序

    # -*- coding: GBK -*- cars = ["bmw", "audi", "toyota", "subaru&qu ...

  7. Python自学:第三章 动手试一试 3-4、3-5

    # -*- coding: GBK -*- liebiao = ["zhang", "li", "wang", "zhou&quo ...

  8. Python自学:第三章 根据值删除元素

    motorcycles = ["honda", "yamaha", "suzuki", "ducati"] print( ...

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

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

随机推荐

  1. IOT

    文档地址:http://www.owasp.org.cn/owasp-project/owasp-things?searchterm=iot 今天面试,面试官问到iot

  2. git for linux使用

    1 Linux下Git和GitHub环境的搭建 第一步: 安装Git,使用命令 “sudo apt-get install git” 第二步: 创建GitHub帐号 第三步: 生成ssh key,使用 ...

  3. python爬虫,爬取一系列新闻

    这个作业的要求来自于:https://edu.cnblogs.com/campus/gzcc/GZCC-16SE2/homework/2941. 由于存在多次请求,所以稍微将请求封装如下 def tr ...

  4. springmvc 配置之 mvc:default-servlet-handler

    配置dispatchServlet的方法一般是: <servlet> <servlet-name>mvc-servlet</servlet-name> <se ...

  5. CCF CSP 201312-2 ISBN号码

    题目链接:http://118.190.20.162/view.page?gpid=T4 问题描述 试题编号: 201312-2 试题名称: ISBN号码 时间限制: 1.0s 内存限制: 256.0 ...

  6. 遍历tr通过name获取对应值用作判断或者赋值

    $("#table tr:gt(0)").each(function(i){ var bidPrice = $("input[name='bidPrice2s']&quo ...

  7. String<-->int

    String s = "123); int a = Integer.parseInt(s); String b = String.valueOf(a); Integer i = 100; 自 ...

  8. Automatically populating $HTTP_RAW_POST_DATA is deprecated......

    Automatically populating $HTTP_RAW_POST_DATA is deprecated... 1 这个问题和PHP版本有关系,PHP 5.6已经废弃了$HTTP_RAW_ ...

  9. flutter 读取sdcard权限问题相关

    https://stackoverflow.com/questions/46698751/permission-denied-at-externalstoragedirectory-access-vi ...

  10. kubernets controller 和 CRD 具体组件分析

    (dlv) b k8s.io/sample-controller/pkg/client/informers/externalversions.(*sharedInformerFactory).Info ...