Python Fundamentals · Collections
A list is an ordered, changeable collection. Use a queue of people to try append, insert, pop, remove and sort.
queue = ["ana", "ben"]
queue.append("cara") # add to the end
queue.insert(0, "dev") # add at a position
served = queue.pop(0) # remove and return the first
queue.remove("ben") # remove by value
queue.sort()
size = len(queue)
print(served, queue, size, "cara" in queue)append adds to the end.insert(0, …) puts "dev" at position 0, pushing everyone back.pop(0) removes the first item and hands it back: "dev" is served.remove("ben") deletes the first item equal to "ben".sort() puts the list in order in place. It changes this list and returns nothing.size is created with the value 2.