s[n] n- , s[0] . , , . , s[-1] . , , IndexError.
s[i:j] s[i:j:step] i j, step.
/ , . (-1 , -2 ..). i / j ( ).
step .
:
a=list(range(0,8,1))
print (a[4:1:-1])
print (a[1:4:1])
:
[4, 3, 2]
[1, 2, 3]
Python , , i, , , j, - . j-i ( , (j-i)/step).
in not in x s. . , hello in hello world True.
sum(s) s, . . . , sum(items, decimal.Decimal(0)) Decimal.
. :
s[i] = x | |
s[i:j] = r | r |
s[i:j:step] = r | |
del s[i] | |
del s[i:j] | |
del s[i:j:step] |
<, >, <=, >=, == !=. . , .
list.append(x)
list.extend(L) list, L
list.insert(i, x) i- x
list.remove(x) , x. ValueError,
|
|
list.pop([i]) i- . ,
list.index(x, [start [, end]]) x ( start end)
list.count(x) x
list.sort([key=])
list.reverse()
list.copy()
list.clear()
L.append (x) | L |
L.count(x) | L |
L.extend(m) L += m | L m; += |
L.index(x, start, end) | () L ( start: end L), ValueError |
L.insert(i, x) | L i |
L.pop() | L |
L.pop(i) | L i |
L.remove(x) | () L ValueError, |
L.reverse() | |
L.sort(...) | . key reverse, sorted() |
i :
L=L[:i]+L[i+1:]
:
<>=[<> for <> in <> if <>]
, . <> , .
:
L = [math.sin(/100) for in range(0, 100)]
, :
L2=[x for x in L1 if not (30<x<70)]
. , . , .
-
range(n1,n2,s) n1 n2 2. , . , , .