291,972 views
30 votes
30 votes
Assign sum_extra with the total extra credit received given list test_grades. Iterate through the list with for grade in test_grades:. The code uses the Python split() method to split a string at each space into a list of string values and the map() function to convert each string value to an integer. Full credit is 100, so anything over 100 is extra credit.Sample output for the given program with input: '101 83 107 90'Sum extra: 8(because 1 + 0 + 7 + 0 is 8)user_input = input()test_grades = list(map(int, user_input.split())) # test_grades is an integer list of test scoressum_extra = 0 # Initialize 0 before your loop''' Your solution goes here '''print('Sum extra:', sum_extra)

User Jeana
by
3.0k points

1 Answer

17 votes
17 votes

Answer:

Replace ''' Your solution goes here '''

With

for i in test_grades:

if i > 100:

sum_extra+=i - 100

Step-by-step explanation:

This iterates through the list

for i in test_grades:

This checks for list elements greater than 100

if i > 100:

The extra digits (above 100) are then added together

sum_extra+=i - 100

User Flob
by
2.7k points