List operations

The + operator concatenates lists:

                       

Similarly, the * operator repeats a list a given number of items:

 

List slices

The slice operator also works on lists:

 

If you omit the first index, the slice starts at the beginning. If you omit the second, the slice goes to the end. So if you omit both, the slice is a copy of the whole list.

from Thinking in Python

原文地址:https://www.cnblogs.com/ryansunyu/p/3841107.html