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

Negative syntax

One more thing you can do is have this negative syntax:

x[-2:]

The output is as follows:

[5, 6]

By saying x[-2:], this means that I want the last two elements in the list. This means that go backwards two from the end, and that will give me 5 and 6, because those are the last two things on my list.

主站蜘蛛池模板: 尖扎县| 资溪县| 名山县| 隆回县| 绵阳市| 临江市| 赣州市| 许昌市| 汉寿县| 蒙阴县| 北流市| 赤壁市| 长沙县| 吴川市| 临沭县| 无极县| 阿合奇县| 巴楚县| 开远市| 宁陵县| 婺源县| 陇西县| 易门县| 辉县市| 神池县| 美姑县| 垫江县| 和平县| 台南县| 孟津县| 车致| 奉节县| 昌图县| 嵩明县| 郧西县| 岑溪市| 高陵县| 山阳县| 九龙城区| 桐梓县| 麻江县|