use a loop to create lists

martaamunar at gmail.com martaamunar at gmail.com
Wed Apr 10 04:40:55 EDT 2013


Hi!

I would like to create a list containing lists. I need each list to have a differente name and i would like to use a loop to name the list. But as the name, is a string, i cannot asign it to a value... how can I do that??


global_list=[]
for i in range (20):
  ("list_"+i)=[]   #These would be the name of the list...
  global_list.append("list_"+i)

Thank you!!!!!




More information about the Python-list mailing list