+ 1
how to optimize python code?
I have a list of lists Like: l = [ ["Mike", 25, 1500], ["Jane", 23, 2000], ["Mike", 25, 750], ] and if first two elements of inner lists are same I want to merge them and sum the third element of them. Like: res = [ ["Mike", 25, 2250], ["Jane", 23, 2000], ] This is my code: https://code.sololearn.com/c7AQiANvinWd/?ref=app
1 Odpowiedź
0
Try using Sets instead! Think about it 😉