-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path7.Lists.py
95 lines (55 loc) · 1.25 KB
/
7.Lists.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
thisList = ["apple", "banana", "orange", "apple", "orange"]
thisLİST = ["tomato", " potato"]
print(thisList)
print(type(thisList))
#Change List Items
thisList[2:3] = ["blackcurrant", "watermelon"]
print(thisList)
thisList[3:6] = ["watermelon"]
print(thisList)
# Add List Items
thisList.insert(2, "cherry") #insert
print(thisList)
thisList.append("apple") #append
print(thisList)
thisList.extend(thisLİST) #extend
print(thisList)
#Remove List Items
thisList.remove("tomato") #remove
print(thisList)
thisList.pop(0) #pop
print(thisList)
del thisList[0] #del
print(thisList)
#thisList.clear()
########
list2 = ["map", 40, "flower"]
print(list2)
print(type(list2))
#Change List Items
print(list2[-1])
print(list2[:3])
print(list2[-2:-1])
if "map" in list2:
print( "Yes, 'map' is in list2" )
# Loop Lists
#For Loop
for x in list2:
print(x)
#While Loop
i = 0
while i < len(list2):
print(list2[i])
i = i+1
list3 = [100, 4, 65, 33, 1]
#Sort List Alphanumerically
list3.sort()
print(list3)
#Copy Lists
mylist = list3.copy()
print(mylist)
mylist =list(list3)
print(mylist)
#Join Two Lists
list4 = list3 + mylist
print(list4)