json_split = {} value = {"Status": "Submitted", "m_Controller": "Python"} a = range(31) del a[0] for i in a: json_split[i] = value keys = json_split.keys() order = list(keys) q1 = int(round(len(keys)*0.2)) q2 = int(round(len(keys)*0.3)) q3 = int(round(len(keys)*0.5)) b = [q1,q2,q3] n=0 threedicts = [] for i in b: queues = order[n:n+i] n = n+i lists = [(queues[j], json_split.get(queues[j])) for j in range(len(queues))] onedict = {} for q in queues: onedict[q] = json_split[q] threedicts.append (onedict) queue1, queue2, queue3 = threedicts keys1 = queue1.keys() for i in keys1: queue1[i]['Priority'] = ['1'] keys2 = queue2.keys() for j in keys2: queue2[j]['Priority'] = ['2'] keys3 = queue3.keys() for z in keys3: queue3[z]['Priority'] = ['3']
I am trying to add a key value pair of ("Priority":"1") to queue1, ("Priority":"2") to queue2, and ("Priority":"3") to queue3. When I just add ("Priority":"1") to queue1, it works. But when I run the above code, ("Priority":"3") is being added to all the queues. This looks trivial and I don't understand why this is happening. Is there something wrong with what I am doing? -- https://mail.python.org/mailman/listinfo/python-list