Debugging Queue
The following implementation has a bug. (Even though the n was supposed to remove the element and the code seems to mean that it does, we still see two items after we removed the first.)
The question is how to debug this?
examples/lists/queue_with_bug.py
q = [] while True: name=input("your name: ") if name=="n": print(q.pop(0)) if name=="x": print(q) exit() if name=="s": print(len(q)) exit() else: q.append(name) continue
your name: Foo your name: Bar your name: n Foo your name: s 2