-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist_obj.py
More file actions
33 lines (24 loc) · 773 Bytes
/
Copy pathlist_obj.py
File metadata and controls
33 lines (24 loc) · 773 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
# Example 5
def main():
# Create an empty list that will hold fabric names.
fabrics = []
# Add three elements at the end of the fabrics list.
fabrics.append("velvet")
fabrics.append("denim")
fabrics.append("gingham")
# Insert an element at the beginning of the fabrics list.
fabrics.insert(0, "chiffon")
print(fabrics)
# Get the index where velvet is stored in the fabrics list.
i = fabrics.index("velvet")
# Replace velvet with taffeta.
fabrics[i] = "taffeta"
print(fabrics)
# Remove the last element from the fabrics list.
fabrics.pop()
# Remove denim from the fabrics list.
fabrics.remove("denim")
print(fabrics)
# Call main to start this program.
if __name__ == "__main__":
main()