I've got a problem of appending elements in multiple lists. My program goes like this. where list is just a series of numbers.
for j in range(0, len(list)):
if (int(list[j][4]) == 0 or int(list[j][:-4]) == 41601000000):
filelist0.append(list[j])
if (int(list[j][4]) == 1 or int(list[j][:-4]) == 41602000000):
filelist1.append(list[j])
if (int(list[j][4]) == 2 or int(list[j][:-4]) == 41603000000):
filelist2.append(list[j])
if (int(list[j][4]) == 3 or int(list[j][:-4]) == 41604000000):
filelist3.append(list[j])
if (int(list[j][4]) == 4 or int(list[j][:-4]) == 41605000000):
filelist4.append(list[j])
if (int(list[j][4]) == 5 or int(list[j][:-4]) == 41606000000):
filelist5.append(list[j])
if (int(list[j][4]) == 6 or int(list[j][:-4]) == 41607000000):
filelist6.append(list[j])
if (int(list[j][4]) == 7 or int(list[j][:-4]) == 41608000000):
filelist7.append(list[j])
if (int(list[j][4]) == 8 or int(list[j][:-4]) == 41609000000):
filelist8.append(list[j])
This is ugly. Is there a way to write the above code in a line or two? Obvious I can iterate strings, but not for the name of the lists. (can't iterate filelist[m] for m in range(0, 9)).
Thanks!
listas a variable name. Subtle mayhem ensues.