Highest Sum of Scores
Here's the appropriate code to print the highest sum of scores:
# Highest sum of scores
group = []
# prompt user to enter an integer that denotes the number of groups
print("Enter integer N: ", end='')
n = int(input())
# prompt user to enter scores of students in each group
print(f"Enter {n} lines of scores (separated by comma):")
for i in range(n):
a = input().split(',')
group.append([])
sum_group = 0
for j in range(len(a)):
group[i].append(int(a[j]))
sum_group += group[i][j]
if i == 0:
max = sum_group
ind_max = i
elif max < sum_group:
max = sum_group
ind_max = i
print('Output:')
for j in range(len(group[ind_max])):
print(group[ind_max][j], end=' ')
Comments
Leave a comment