-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmap.py
More file actions
67 lines (38 loc) · 980 Bytes
/
Copy pathmap.py
File metadata and controls
67 lines (38 loc) · 980 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
a = [1, 2, 3, 4]
# Using lambda function in "function" parameter
# to double each number in the list
print(list(map(lambda x: x * 2, a)))
res = list(map(lambda x: x * 2, a))
print(res)
fruits = ["apple", "banana", "cherry"]
res = map(str.upper, fruits)
print(list(res))
print(list(map(str.capitalize, fruits)))
words = ["apple", "banana", "cherry"]
res = map(lambda x: x[0], words)
print(list(res))
def foo(a, b, c):
print(a, b, c)
obj = {"a": 20, "b": 10, "c": "lee"}
foo(**obj)
def fun(**kwargs):
for k, val in kwargs.items():
print(k, val)
fun(a=1, b=2, c=3)
def foo1(**kwargs):
for key, value in kwargs.items():
print("Valie is {} and {}".format(key, value))
foo1(name="test", test=40)
lst = [11, 22, 33, 44, 55]
iter_lst = iter(lst)
while True:
try:
print(iter_lst.__next__())
except:
break
iter_lst = iter(lst)
while True:
try:
print(iter_lst.__next__())
except:
break