A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
5
Task/Filter/Python/filter-1.py
Normal file
5
Task/Filter/Python/filter-1.py
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
values = range(10)
|
||||
evens = [x for x in values if not x & 1]
|
||||
ievens = (x for x in values if not x & 1) # lazy
|
||||
# alternately but less idiomatic:
|
||||
evens = filter(lambda x: not x & 1, values)
|
||||
2
Task/Filter/Python/filter-2.py
Normal file
2
Task/Filter/Python/filter-2.py
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
values = range(10)
|
||||
evens = values[::2]
|
||||
4
Task/Filter/Python/filter-3.py
Normal file
4
Task/Filter/Python/filter-3.py
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
values = range(10)
|
||||
values[::2] = [11,13,15,17,19]
|
||||
print values
|
||||
11, 1, 13, 3, 15, 5, 17, 7, 19, 9
|
||||
Loading…
Add table
Add a link
Reference in a new issue