exec - How to make a dictionary or many lists using for loops and name each a different name in python -


i have lot of text files want import. each txt file has 10 numbers , want make list each file or dictionary whole. figured out how name lists list1, list2, list3... not know how append. want do

list1.append(txt1) list2.append(txt2) list3.append(txt3) ... ... 

you can take advantage of exec command this. not need append

for i,f in enumerate(filelist):     exec "list%s = f" %i 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -