python list | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

python list

hi how can i sum second elements of indexes that have same first element in this list? initial list = [['p2', 0], ['p1', 0], ['p3', 0], ['p2', 4], ['p4', 6]] result = [['p2', 4], ['p1', 0], ['p3', 0], ['p4', 6]]

10th Nov 2021, 12:36 PM
nima rasi
2 Answers
10th Nov 2021, 1:42 PM
Oma Falk
Oma Falk - avatar
0
https://code.sololearn.com/c2p20Kq9XkUd/?ref=app
11th Nov 2021, 2:33 AM
Vitaly Sokol
Vitaly Sokol - avatar