In the create_dict function, you have the following code:
roundlist = [] while len(roundlist)<rounds: roundlist.append(0) for k in sorted(data.keys()): if k.startswith('BTC'): cur_dict.update({k:roundlist})
That is, you create one list and assign it to each key in the dictionary.
Here it is necessary to understand that although you have written it many times in the dictionary this way, it still remains the same list.
Naturally, when you change it through one of the keys, it immediately changes across all other keys. Just because it’s actually the same list.
To make it work, you need to rewrite the function like this:
def create_dict(rounds): cur_dict = {} s = requests.session() r = s.get('https://poloniex.com/public?command=returnTicker') data = r.json() for k in sorted(data.keys()): if k.startswith('BTC'): cur_dict.update({k: [0 for _ in range(rounds)]}) return cur_dict
This code will create a truly separate list for each key.
PS: When you ask more questions on stackoverflow, follow the requirements for the design of questions.
PPS: By the way, I didn’t understand why you are sorting the dictionary keys before iterating over them. Does this have some kind of sacred meaning?