list of the lists - append after search
Andrew Zyman
formisc at gmail.com
Thu Mar 2 11:02:45 EST 2017
Hello,
please advise.
I'd like search and append the internal list in the list-of-the-lists.
Example:
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'])
output:
ValueError: [['blah', 1]] is not in list
thank you
AZ
More information about the Python-list
mailing list