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. 铁大Facebook隐私保护NABCD

    隐私保护功能: N:满足了用户保护自己隐私信息的需求 A:对每一项用户可能需要保护的信息,我们都会添加仅自己可见.指定人可见.部分人可见或所有人可见设置 B:让用户的信息受到更全面的保护,而不仅仅是对 ...

  2. python爬虫中scrapy框架是否安装成功及简单创建

    判断框架是否安装成功,在新建的爬虫文件夹下打开盘符中框输入cmd,在命令中输入scrapy,若显示如下图所示,则说明成功安装爬虫框架: 查看当前版本:在刚刚打开的命令框内输入scrapy versio ...

  3. Centos7 下安装mysql5.7.17(glibc版)

    一.安装前的检查 1.1 检查 linux 系统版本 [root@localhost ~]# cat /etc/system-release 1.2 检查是否安装了 mysql [root@local ...

  4. ngx-admin with Asp.net Core 2.0, possibly plus OrchardCore

    1 Download ngx-admin from https://github.com/akveo/ngx-admin 2 Create a new Web Application in vs201 ...

  5. 类与对象 && 继承

      以下是本人的对类与对象.继承的一些理解,如有错误之处万望谅解,如有朋友愿意指正,十分乐意,万分感谢!   类与对象     类与对象是学习编程的基础(大概吧),那么何为类?何为对象呢?   一.简 ...

  6. vue单文件组件实例1:简单单文件组件

    ​ HelloWorld.vue: <template> <div class="hello"> <h1>{{msg}}</h1> ...

  7. ts --基础类型

    声明js的基本类型1.数字let a: number = 2; 2.字符串let aa: string = "22" 3.数组 (1) 数组元素: let b: number[] ...

  8. GO函数

    函数定义 Go语言中定义函数使用func关键字. func 函数名(参数)(返回值){ 函数体 } 函数名:由字母.数字.下划线组成.但函数名的第一个字母不能是数字.在同一个包内,函数名也称不能重名( ...

  9. python模块部分----模块、包、常用模块

    0.来源:https://www.cnblogs.com/jin-xin/articles/9987155.html 1.导入模块 1.1模块就是一个python文件,模块名是文件名 1.2导入模块的 ...

  10. react小知识点

    1.render函数什么时候会执行? 当this.state/this.props发生改变的时候render函数就会执行 2.组件第一次执行的时候会执行哪些生命周期 constructor--> ...