-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLists.py
More file actions
55 lines (42 loc) · 894 Bytes
/
Lists.py
File metadata and controls
55 lines (42 loc) · 894 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
# Program to demonstrate lists
# Declare list
list = ["Gallen", "Jeremy", 38]
# Print type
print(type(list))
# Print list
print(list)
# Print individual list elements
print(list[0])
print(list[1])
print(list[2])
# Change list elements
list[0] = "Jeremy"
list[1] = "Gallen"
# Display changed list and individual elements
print(list)
print(list[0])
print(list[1])
# Display element range
print(list[0:2])
# Append and display list
list.append("United States")
print(list)
# Pop and display list
list.pop()
print(list)
# Insert element into list and display
list.insert(1, "Michael")
print(list)
# Reverse and display list
list.reverse()
print(list)
# Edit, print, sort, and redisplay
list[1] = 24
list[2] = 42
list[3] = 55
print(list)
list.sort()
print(list)
# Add and display, multiply and display
print(list+list)
print(list*3)