首页 > 代码库 > List operations

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