PY
py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
L = [i for i in range(0,11)]
# I can't understand as
x = map(lambda a : True if (a%2 == 0) else False, L)
new = []
#output = [True, False, True, False, True, False, True, False, True, False, True]
for i in x:
new.append(i)
print(new)
#and
x = filter(lambda a : True if (a%2 == 0) else False, L)
new = []
#output = [0,2,4,6,8,10]
for i in x:
new.append(i)
print(new)
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run