-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtutorial007_pythonLists_part2.py
More file actions
93 lines (57 loc) · 937 Bytes
/
tutorial007_pythonLists_part2.py
File metadata and controls
93 lines (57 loc) · 937 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
68
69
70
71
72
73
74
75
76
'''
List: Values, Indexing, and Methods
'''
# List
l1 = [7, 6, 8, 4, 5, 9, 1]
# print(l1)
# Appending - add entry in the end
l1.append(10)
# print(l1)
# Insert - add entry on the given index
l1.insert(6, 22)
# print(l1)
# Extending list
l2 = ["John", "Bruce,", "Diana", "Hal", "Barry"]
l1.extend(l2)
# print(l1)
# Copy
# l3 = l2
# print(l3)
# print(id(l3), id(l2))
# l3.append("Clarke")
# print(l2)
# print(id(l3), id(l2))
l4 = l2.copy()
# print(id(l2), id(l4))
# Clear
# print(l4)
# l4.clear()
# print(l4)
# Count
l5 = [1, 3, 4, 1, 4, 5, 1, 2, 2, 2, 1]
# print(l5.count(2))
# Sort
print(l5)
l5.sort()
print(l5)
# index
l6 = [1, 3, 4, 1, 4, 5, 1, 2, 2, 11, 2, 1]
print(l6.index(11))
# Pop
print(l6)
last = l6.pop()
print(last, l6)
# Remove
print(l6)
l6.remove(2)
print(l6)
# del
print(l6)
del l6[5]
print(l6)
# Reverse
print(l6)
l6.reverse()
print(l6)
# len, max, min
print(len(l6), max(l6), min(l6))