my study question is: Define a procedure, total_enrollment, that takes as an input a list of elements, where each element is a list containing three elements: a university name, the total number of students enrolled, and the annual tuition fees.
The procedure should return two numbers, not a string, giving the total number of students enrolled at all of the universities in the list, and the total tuition fees (which is the sum of the number of students enrolled times the tuition fees for each university).
the code given is:
usa_univs = [ ['California Institute of Technology',2175,37704],
['Harvard',19627,39849],
['Massachusetts Institute of Technology',10566,40732],
['Princeton',7802,37000],
['Rice',5879,35551],
['Stanford',19535,40569],
['Yale',11701,40500] ]
my solution is:
def total_enrollment(a):
total_students = 0
costsum = 0
for e in a:
total_students = total_students + e[1]
costsum = costsum + e[2]
all_in_all = total_students * costsum
return total_students
return all_in_all
what I should see is: 77285,3058581079
What actually comes out is: 77285 - and no total number