PLEASE HELP ME! I'M SUPER NEW AT THIS AND THINK I'VE GONE COMPLETELY OFF SOMEWHERE.
I Was given a csv file to use and extrapolate data from. Had a pretty extensive list of countries with their corresponding GDPs, unemployment rates and more. I'm mean to 1. Provide the country with the highest GDP in the list, and 2. Determine if this country has below average unemployment rate to go with it. I was able to get through the data definitions OK (I think) but I'm running into problems when I try to find the average unemployment rate in the given list (I used named tuple to organize the list by unemployment rate and country name).
def highest_gdp(logdp:List[CountryGDP])-> str:
"""
returns the name of the country with the highest GDP
"""
#Return "" #body of the stub
#template from List[CountryGDP]
highest = logdp[0] #type: CountryGDP
for gdp in logdp:
if gdp.cgdp >= highest.cgdp:
highest = gdp
return highest.name
def average_unemployment(louemp:List[Unemployment])-> float:
"""
returns the average unemployment rate of the given list
"""
#return 0 #body of the stub
#template from List[Unemployment]
average = louemp[0] #type: Unemployment
for uemp in louemp:
if uemp.rate > 0:
average = uemp
return sum(uemp.rate)/float(len(louemp))
The first section is correct, I think. No errors were returned when I ran it, but I can't seem to figure out the second one that would be returning the average unemployment rate!! I keep getting various kinds of error messages, no matter what I try! I know this is super basic, but please help!!!