- Hands-On Data Science and Python Machine Learning
- Frank Kane
- 153字
- 2021-07-15 17:15:00
Adding list to list
You can also change lists around. Let's say I want to add a list to the list. I can use the extend function for that, as shown in the following code block:
x.extend([7,8])
x
The output of the above code is as follows:
[1, 2, 3, 4, 5, 6, 7, 8]
I have my list of 1, 2, 3, 4, 5, 6. If I want to extend it, I can say I have a new list here, [7, 8], and that bracket indicates this is a new list of itself. This could be a list implicit, you know, that's inline there, it could be referred to by another variable. You can see that once I do that, the new list I get actually has that list of 7, 8 appended on to the end of it. So I have a new list by extending that list with another list.
推薦閱讀
- Docker技術(shù)入門與實戰(zhàn)(第3版)
- Microsoft Application Virtualization Cookbook
- jQuery EasyUI網(wǎng)站開發(fā)實戰(zhàn)
- Servlet/JSP深入詳解
- JAVA程序設(shè)計實驗教程
- VMware虛擬化技術(shù)
- Learning Laravel's Eloquent
- Learning Continuous Integration with TeamCity
- 時空數(shù)據(jù)建模及其應(yīng)用
- Developing SSRS Reports for Dynamics AX
- 并行編程方法與優(yōu)化實踐
- Learning Unreal Engine Game Development
- AutoCAD基礎(chǔ)教程
- C++17 By Example
- HTML并不簡單:Web前端開發(fā)精進(jìn)秘籍