- Hands-On Penetration Testing with Python
- Furqan Khan
- 132字
- 2021-07-02 14:13:50
Merging and updating lists
List merging can be done in two ways in Python. First, we can use the traditional + operator, which we used previously to concatenate two strings. It does the same when used on list object types. The other way to achieve this would be by using the extend method, which takes the new list as an argument to be merged with the existing list. This is shown in the following example:

To update an element in the list, we can access its index and add the updated value for any element that we wish to update. For example, if we want to have the string Hello as the 0th element of the list, this can be achieved by assigning the 0th element to the Hello value as merged[0]="hello":

推薦閱讀
- Expert C++
- Progressive Web Apps with React
- Apache ZooKeeper Essentials
- Cocos2d-x游戲開發:手把手教你Lua語言的編程方法
- Java應用開發與實踐
- 網頁設計與制作教程(HTML+CSS+JavaScript)(第2版)
- Reactive Programming With Java 9
- Yocto for Raspberry Pi
- 組態軟件技術與應用
- 大數據分析與應用實戰:統計機器學習之數據導向編程
- 響應式Web設計:HTML5和CSS3實戰(第2版)
- Python從入門到精通(第3版)
- Machine Learning for Developers
- C++程序設計教程(第2版)
- Visual Basic程序設計全程指南