-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathh10.py
More file actions
34 lines (32 loc) · 983 Bytes
/
h10.py
File metadata and controls
34 lines (32 loc) · 983 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
number_of_commands = int(input("Enter number of commands: "))
counter = 0
items_list = []
while counter < number_of_commands:
command = input(f"Enter command {counter + 1}: ")
operation_item = command.split(" ")
operation = operation_item[0]
if(operation == "insert" or operation == "remove" or operation == "append"):
item = int(operation_item[1])
if operation == "insert":
index = int(operation_item[1])
item = int(operation_item[2])
items_list.insert(index,item)
elif operation == "print":
print(items_list)
elif operation == "remove":
items_list.remove(item)
elif operation == "append":
items_list.append(item)
elif operation == "sort":
items_list.sort()
elif operation == "pop":
items_list.pop()
elif operation == "reverse":
items_list.reverse()
counter += 1
stack = []
stack.insert(3, 6)
stack.append(5)
print(stack)
stack.remove(6)
print(stack)