neponemayu nichego chto proishodit | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

neponemayu nichego chto proishodit

the program should output the sum of the maxima of each row of the 2x2 matrix. how should the last lines be written so that it is more clear what is happening? https://code.sololearn.com/cWSzDO06egS6/?ref=app

11th Apr 2020, 4:49 PM
shiryaeva
shiryaeva - avatar
5 Answers
+ 3
sum = 0 max = 0 for row in a: #for i in range(0, n): #if a[i][j] >= max: #max = a[i][j] sum += max(row) print(sum)
11th Apr 2020, 5:18 PM
Oma Falk
Oma Falk - avatar
+ 3
sum = 0 max = 0 for row in a: max =0 for num in row: if num >= max: max = num sum += max print(sum)
11th Apr 2020, 5:26 PM
Oma Falk
Oma Falk - avatar
+ 1
Thank you very much!!!🌺
11th Apr 2020, 5:36 PM
shiryaeva
shiryaeva - avatar
0
unfortunately I am forbidden to use the max () function
11th Apr 2020, 5:22 PM
shiryaeva
shiryaeva - avatar
0
so many mistakes. for row in a: but a isn’t defined. no variable for a. Next is sum+= max. you used a wrong indentation and so on
12th Apr 2020, 12:20 AM
Ken Bryan
Ken Bryan - avatar