-
Notifications
You must be signed in to change notification settings - Fork 0
/
lists.py
90 lines (74 loc) · 1.63 KB
/
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
thislist = ["apple", "orange", "cherry"]
print(thislist)
print()
print(thislist[0])
print()
print(thislist[-2])
print()
mylist = ["apple", "banana", "cherry", "orange", "kiwi", "melon", "mango"]
print(mylist[2:5])
print()
print(mylist[:6])
print()
print(mylist[1:])
print()
print(mylist[-4:-1])
print()
if "mango" in mylist:
print("Yes, 'mango' is in the fruits list")
print()
mylist[1]="blackcurrent"
print(mylist)
print()
mylist[1:3]=["blackcurrant", "watermelon"]
print(mylist)
print()
thislist[1:2]=["blackcurrant", "watermelon"]
print(thislist)
print()
mylist=["apple", "banana", "cherry"]
mylist.insert(2,"watermelon")
print(mylist)
print()
mylist=["apple", "banana", "cherry"]
mylist.append("orange")
print(mylist)
print()
thislist=["apple", "banana", "cherry"]
tropical=["mango", "pineapple", "pappaya"]
thislist.extend(tropical)
print(thislist)
print()
tropical.append("orange")
print(tropical)
print()
thislist=["apple", "banana", "cherry"]
thistuple=("mango", "pineapple", "pappaya")
thislist.extend(thistuple)
print(thislist)
print()
thislist = ["apple", "banana", "cherry"]
thislist.remove("banana")
print(thislist)
print()
thislist = ["apple", "banana", "cherry", "banana", "kiwi"]
thislist.remove("banana")
print(thislist)
print()
thislist = ["apple", "banana", "cherry"]
thislist.pop(1)
print(thislist)
print()
thislist.pop()
print(thislist)
print()
thislist = ["apple", "banana", "cherry"]
del thislist[0]
print(thislist)
print()
del thislist
print(thislist)
print()
thislist = ["apple", "banana", "cherry"]
thislist.clear()
print(thislist)