list of the lists - append after search

Andrew Zyman formisc at
Thu Mar 2 11:02:45 EST 2017

 please advise.

 I'd like search and append the internal list in the list-of-the-lists.

 ll =[ [a,1], [b,2], [c,3], [blah, 1000] ]

 i want to search for the internal [] based on the string field and, if matches, append that list with a value.

  if internal_list[0] == 'blah':
      ll[ internal_list].append = [ 'new value']

End result:
 ll =[ [a,1], [b,2], [c,3], [blah, 1000, 'new value'] ]

I came up with the following, but the second stmnt is not correct:

print [x for x in ll if x[0]== 'blah']
print ll.index([x for x in ll if x[0]=='blah'])

ValueError: [['blah', 1]] is not in list

thank you

More information about the Python-list mailing list