官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 丘北县| 孟连| 根河市| 大宁县| 龙川县| 江川县| 凤冈县| 麻城市| 巩义市| 盱眙县| 景德镇市| 龙州县| 灵宝市| 三明市| 和硕县| 蚌埠市| 横峰县| 霍邱县| 榆树市| 嘉义市| 六枝特区| 德保县| 阿坝| 安平县| 莫力| 石渠县| 尼木县| 镇平县| 四川省| 西峡县| 崇明县| 翁牛特旗| 津南区| 金秀| 特克斯县| 临颍县| 天气| 宿州市| 正安县| 阿图什市| 东乌|