I have a function as follows:
def control(qstat):
gatnum = int(input("What number of control gates is this control qubit a part of?"))
global qstatnum
qstatnum = {}
qstatnum[gatnum] = []
qstatnum[gatnum].append(qstat) #seems to be a problem
return qstat
However, there is a problem. Let's say I run it once. There will be one item in the list. Then, I run it a second time, with an item distinguishable from the second supposed to be added to the list. When I print qstatnum[gatnum]
, the list contains only the second item, leading me to believe that the .append()
statement is somehow incorrectly written and overwriting any previous additions to the list.
Is this a correct diagnosis? Why would this be? Any help would be appreciated. Thanks!