There are two lists

a = [401, 604, 547, 700, 722, 845, 621, 490, 800, 700] b = [900, 0, 333, 803, 838, 400, 467, 488, 432, 700] 

It is necessary to compare among themselves the elements of lists so that the new list consists of numbers that are larger. Those.

 [900, 604, 547, 803, 838, 845, 621, 490, 800, 700]. 

And to display the sum of these elements i. Сумма: 7148

  • 2
    tell us what you were trying to do, what didn’t work, lay out your code. - pavel

3 answers 3

 a = [401, 604, 547, 700, 722, 845, 621, 490, 800, 700] b = [900, 0, 333, 803, 838, 400, 467, 488, 432, 700] c = [] for i in range(len(a)): c.append(max(a[i], b[i])) print(sum(c)) 
     a = [401, 604, 547, 700, 722, 845, 621, 490, 800, 700] b = [900, 0, 333, 803, 838, 400, 467, 488, 432, 700] c = [max(x, y) for x, y in zip(a, b)] print(c) [900, 604, 547, 803, 838, 845, 621, 490, 800, 700] print(sum(c)) 7148 
    • You can simply: sum(map(max, zip(a, b))) - jfs
     new_list = [max(a[i], b[i]) for i in range(len(a))] list_sum = sum(new_list) 

    PS generators run faster cycles