- 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.
推薦閱讀
- Vue.js設(shè)計(jì)與實(shí)現(xiàn)
- PostgreSQL Cookbook
- Python高效開發(fā)實(shí)戰(zhàn):Django、Tornado、Flask、Twisted(第2版)
- SAS數(shù)據(jù)統(tǒng)計(jì)分析與編程實(shí)踐
- Swift細(xì)致入門與最佳實(shí)踐
- jQuery Mobile移動(dòng)應(yīng)用開發(fā)實(shí)戰(zhàn)(第3版)
- Python極簡(jiǎn)講義:一本書入門數(shù)據(jù)分析與機(jī)器學(xué)習(xí)
- 案例式C語(yǔ)言程序設(shè)計(jì)實(shí)驗(yàn)指導(dǎo)
- 精通MySQL 8(視頻教學(xué)版)
- Hadoop 2.X HDFS源碼剖析
- C++ System Programming Cookbook
- Scrapy網(wǎng)絡(luò)爬蟲實(shí)戰(zhàn)
- Visual C++程序設(shè)計(jì)與項(xiàng)目實(shí)踐
- 計(jì)算機(jī)應(yīng)用基礎(chǔ)案例教程(第二版)
- Elastix Unified Communications Server Cookbook