I have a list of lists of numbers like this excerpt. ['0', '0', '0', '0'] ['0', '0', '0', '0'] ['0', '0', '0', '0'] ['0', '0', '0', '0'] ['0', '0', '0', '0'] ['0', '0', '0', '0'] ['7', '2', '1', '0', '142647', '00'] ['7', '2', '0', '1', '87080', '00'] ['6', '1', '1', '1', '51700', '00'] ['4', '1', '1', '0', '36396', '00']
I want to go threw and for each index error at [4] append a 0. I have called the lists fups. p = re.compile('\d+') fups = p.findall(nomattr['firstup']) [x[4] for x in fups if IndexError fups.append(0)] print(fups) Unsure why I cannot use append in this instance, how can I modify to acheive desired output? Desired Output ['0', '0', '0', '0', '0'] ['0', '0', '0', '0', '0'] ['0', '0', '0', '0', '0'] ['0', '0', '0', '0', '0'] ['0', '0', '0', '0', '0'] ['0', '0', '0', '0', '0'] ['7', '2', '1', '0', '142647', '00'] ['7', '2', '0', '1', '87080', '00'] ['6', '1', '1', '1', '51700', '00'] ['4', '1', '1', '0', '36396', '00'] Thanks Sayth -- https://mail.python.org/mailman/listinfo/python-list