Python自学:第三章 根据值删除元素
Posted Johnson蚂蚁
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Python自学:第三章 根据值删除元素相关的知识,希望对你有一定的参考价值。
motorcycles = ["honda", "yamaha", "suzuki", "ducati"] print(motorcycles) motorcycles.remove("ducati") print(motorcycles)
输出为:
[‘honda‘, ‘yamaha‘, ‘suzuki‘, ‘ducati‘] [‘honda‘, ‘yamaha‘, ‘suzuki‘]
2、
motorcycles = ["honda", "yamaha", "suzuki", "ducati"] print(motorcycles) too_expensive = "ducati" motorcycles.remove(too_expensive) print(motorcycles) print(" A " + too_expensive.title() + " is too expenfive for me.")
输出为:
[‘honda‘, ‘yamaha‘, ‘suzuki‘, ‘ducati‘] [‘honda‘, ‘yamaha‘, ‘suzuki‘] A Ducati is too expenfive for me.
以上是关于Python自学:第三章 根据值删除元素的主要内容,如果未能解决你的问题,请参考以下文章
一个新手的Python自学之旅 #MacBook #《“笨办法”学Python》#第三章:言归正传讲Python:Mac系统的终端Terminal命令行快速入门