0

I would like to name a new list from a string in a list, for example if I have a string 'A' create the list A[].

In my case :

fieldList = ["A", "B","C","D"]

for field in fieldList:
    listname = "data_{0}".format(field)
    print listname

I want 4 new lists

data_A=[]
data_B=[]
data_C=[]
data_D=[]

It seems easy but I can't find a way to do it.

Victor A
  • 55
  • 5
  • Why do you want this? How will you refer to these variables afterwards? – Useless Jun 29 '17 at 11:37
  • 2
    Dynamically creating variables in Python is possible, but it's quirky. Is there a specific reason why you can't use a ``dict`` instead? – Mike Scotty Jun 29 '17 at 11:37

0 Answers0