I have a nest list:
listSchedule = [[list1], [list2], etc..]]
I have another list and I want to append to each nested list the element of this list if the first element of each matches a string.
I can do it but I wonder if there is a more 'pythonic' way, using list comprehension?
index = 0;
for row in listSchedule:
if row[0] == 'Download':
row[3] = myOtherList[index]
index +=1
dict(or ifDownloadmight appear multiple times, a multi-dictlikecollections.defaultdict(list)) or something? Needing to loop over every element to find a "header" to append data to sounds an awful lot like the case where you'd want adict.IndexError, since it assigns torow[3], but thelistScheduleyou provided is alistof len 1lists, so any index butrow[0]would error out.