Review this code. Predict two calls to add("a"), then add("b"). Repair it, and explain whether a shallow copy solves every shared-state problem.
def add(item, queue=[]):
queue.append(item)
return queueIntermediate · Engineering discussion
functions · ownership · debugging
Guest practice stays in this visit. Sign in to save your progress. Checks cover the stated cases; discussion rubrics are self-reviewed. These tasks do not mark course lessons complete.
Review this code. Predict two calls to add("a"), then add("b"). Repair it, and explain whether a shallow copy solves every shared-state problem.
def add(item, queue=[]):
queue.append(item)
return queue