mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
#20740: desquarify 2.
This commit is contained in:
parent
94ee389308
commit
6b532349d0
1 changed files with 4 additions and 4 deletions
|
|
@ -371,9 +371,9 @@ values. The most versatile is the *list*, which can be written as a list of
|
||||||
comma-separated values (items) between square brackets. Lists might contain
|
comma-separated values (items) between square brackets. Lists might contain
|
||||||
items of different types, but usually the items all have the same type. ::
|
items of different types, but usually the items all have the same type. ::
|
||||||
|
|
||||||
>>> squares = [1, 2, 4, 9, 16, 25]
|
>>> squares = [1, 4, 9, 16, 25]
|
||||||
>>> squares
|
>>> squares
|
||||||
[1, 2, 4, 9, 16, 25]
|
[1, 4, 9, 16, 25]
|
||||||
|
|
||||||
Like strings (and all other built-in :term:`sequence` type), lists can be
|
Like strings (and all other built-in :term:`sequence` type), lists can be
|
||||||
indexed and sliced::
|
indexed and sliced::
|
||||||
|
|
@ -389,12 +389,12 @@ All slice operations return a new list containing the requested elements. This
|
||||||
means that the following slice returns a new (shallow) copy of the list::
|
means that the following slice returns a new (shallow) copy of the list::
|
||||||
|
|
||||||
>>> squares[:]
|
>>> squares[:]
|
||||||
[1, 2, 4, 9, 16, 25]
|
[1, 4, 9, 16, 25]
|
||||||
|
|
||||||
Lists also supports operations like concatenation::
|
Lists also supports operations like concatenation::
|
||||||
|
|
||||||
>>> squares + [36, 49, 64, 81, 100]
|
>>> squares + [36, 49, 64, 81, 100]
|
||||||
[1, 2, 4, 9, 16, 25, 36, 49, 64, 81, 100]
|
[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
|
||||||
|
|
||||||
Unlike strings, which are :term:`immutable`, lists are a :term:`mutable`
|
Unlike strings, which are :term:`immutable`, lists are a :term:`mutable`
|
||||||
type, i.e. it is possible to change their content::
|
type, i.e. it is possible to change their content::
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue