-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfruit.py
More file actions
35 lines (25 loc) · 873 Bytes
/
Copy pathfruit.py
File metadata and controls
35 lines (25 loc) · 873 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
def main():
try:
# Create and print a list named fruit.
fruit_list = ["pear", "banana", "apple", "mango"]
print(f"original: {fruit_list}")
fruit_list.reverse()
print(f"reverse: {fruit_list}")
fruit_list.append("orange")
print(f"append: {fruit_list}")
index = fruit_list.index("apple")
fruit_list.insert(index, "cherry")
print(f"insert: {fruit_list}")
fruit_list.pop(1)
print(f"pop: {fruit_list}")
fruit_list.pop()
print(f"pop: {fruit_list}")
fruit_list.sort()
print(f"sort: {fruit_list}")
fruit_list.clear()
print(f"clear: {fruit_list}")
except IndexError as index_err:
print(type(index_err).__name__, index_err, sep=": ")
# Call main to start this program.
if __name__ == "__main__":
main()