-
Notifications
You must be signed in to change notification settings - Fork 0
/
Lists.py
51 lines (37 loc) · 905 Bytes
/
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
friends = ["Ralph", "Tashinga", "Rutendo", "Fortunate", "Olivia"]
print(friends)
print(friends[0])
print(friends[2])
print(friends[-1])
print(friends[-2])
print(friends[1:])
print(friends[1:3])
friends[1] = "Alice"
print(friends[1])
print(friends)
print("LIST FUNCTIONS")
lucky_numbers = [40, 8, 15, 16, 23, 42 ]
friends = ["Ralph", "Tashinga", "Rutendo", "Fortunate", "Olivia"]
print(friends)
friends.sort()
print(friends)
lucky_numbers.sort()
print(lucky_numbers)
lucky_numbers.reverse()
print(lucky_numbers)
friend2 =friends.copy()
print(friend2)
friends.extend(lucky_numbers)
print(friends)
friends.append("Paul")
print(friends)
friends.insert(1, "Karen")
print(friends)
friends.remove("Ralph")
print(friends)
print(friends.index("Rutendo"))
print(friends.count("Fortunate"))
friends.pop()
print(friends)
friends.clear()
print(friends)