File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ This guide includes a list of several and useful `Python` data structures to kno
1111It is intended to show the main data structures incorporated in the language
1212and their useful functions. More advance ` Python ` feature will not be shown here.
1313
14- Additional links :
14+ Additional material :
1515
1616| ** Topic** | ** Link** |
1717| ---| ---|
159159' a'
160160
161161# Slicing
162- >> > l[:] # `l[start:end]` where ` end` is exclusive
162+ >> > l[:] # `l[start:end]` which means `[start, end)`
163163[1 , 2 , ' a' ]
164164>> > l[0 :len (l)] # `start` is 0 and `end` is `len(l)` if omitted
165165[1 , 2 , ' a' ]
176176>> > l.remove(' b' ) # `ValueError: list.remove(x): x not in list`
177177>> > l
178178[2 ]
179- >> > l.index(2 )
179+ >> > l.index(2 ) # It returns first occurrence (`O(n)`)
1801800
181181>> > l.index(12 ) # `ValueError: 12 is not in list`
182182
1881885
189189>> > [k for k in range (5 )]
190190[0 , 1 , 2 , 3 , 4 ]
191+ >> > [k for k in reversed (range (5 ))]
192+ [4 , 3 , 2 , 1 , 0 ]
191193
192194# Compact way to define 2D arrays
193195>> > rows, cols = 2 , 3
199201
200202# Built-in methods
201203>> > l = [2 , 1 , 4 , 3 ]
204+ >> > len (l)
205+ 4
202206>> > min (l)
2032071
204208>> > max (l)
@@ -496,7 +500,7 @@ Point(x=1, y=2)
496500True
497501
498502# Python >= 3.6.1
499- >> > from typing import Any, NamedTuple
503+ >> > from typing import NamedTuple
500504>> >
501505>> > class Point (NamedTuple ):
502506... x: int
You can’t perform that action at this time.
0 commit comments