Iterate a dict name in a loop
Hi everyone, I'm learning python for few days now and there is something I fail to do, and didnt find any answer on the web yet. I want to create multiple dict in a for loop: It looks like this: for i < 5: dict_name"i" = {"test": i} i +=1 What I want in result is: dict_name0 = {"test":0} dict_name1 = .... 1} ... dict_name4= ...4} I simplified the code there, but the real goal is to assign a full line of a file into a dict. Its working but with list: book_list = [] with open('testbook.txt','r') as indexing: for line in indexing: book_list = [line.strip() for line in indexing] Is there a way to change dynamically a name of a dict? Even with print command? for i < 5: print (dict_name"i" + ",") result wanted: dict_name0,dict_name1, ... ,dict_name4 #print all items of dict Thank you for your help. If you need more details just ask :)