-
Notifications
You must be signed in to change notification settings - Fork 0
/
List Comprehension.py
59 lines (53 loc) · 1.13 KB
/
List Comprehension.py
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
liste=[1,2,3,4,5,6,9]
"""list1=[]
for i in list:
list1.append(i)
print(list1)
list2=[i for i in liste]
print(list2)"""
"""list1=[]
for i in list:
list1.append(i*i)
print(list1)
list2=[i*i for i in liste]
print(list2)"""
"""list1=[]
for i in liste:
if i%2 ==0:
list1.append(i)
print(list1)
list2=[i for i in liste if i%2 ==0]
print(list2)"""
"""list1=[]
for i in list:
if i%2 ==0:
continue
list1.append(i)
print(list1)
list2=[i for i in list if not i%2 ==0]
print(list2)"""
"""list1=[]
letter="abc"
for i in liste:
for j in letter:
list1.append((i,j))
print(list1)
list2=[(i,j) for i in liste for j in letter]
print(list2)"""
"""list_=[(1,2,3),(4,5,6),(7,8,9)]
list1=[]
for i in list_:
for j in i:
list1.append(j)
print(list1)
list2=[j for i in list_ for j in i]
print(list2)"""
print(dir(list))
list_method=[]
for method in dir(list):
if method.startswith("__"):
continue
list_method.append(method)
print(list_method)
list_method1=[method for method in dir(list) if not method.startswith("__")]
print(list_method1)