A list holds values in order: queue = ["Ann", "Ben"]. Items are numbered from zero, queue[0] is the first and queue[-1] the last, and len(queue) is the count. Lists are mutable: .append(x) adds to the end, .insert(i, x) puts x at position i, .remove(x) deletes the first matching value, and .pop() removes and returns the last item (or .pop(i) for position i).
Lists can hold anything, including other lists, and a variable holding a list is a reference: b = a makes both names point at the same list, so changing one changes the other. Use a.copy() when you want an independent copy.
stack = [1, 2]
stack.append(3) # [1, 2, 3]
stack.insert(0, 0) # [0, 1, 2, 3]
stack.remove(2) # [0, 1, 3]
last = stack.pop() # 3, stack is [0, 1]Your task
Starting from the queue in the starter, append "Cai", insert "Zed" at the front, and remove "Ben". Then set first to the first item, last to the last item, and size to the length.
Hint 1
queue.insert(0, "Zed") puts it at the front.
Hint 2
queue[-1] is the last item; len(queue) is the size.
Show the solution
queue = ["Ann", "Ben"]
queue.append("Cai")
queue.insert(0, "Zed")
queue.remove("Ben")
first = queue[0]
last = queue[-1]
size = len(queue)