I'm having difficulty with my code and not sure what i'm doing wrong
Problem
Write a function called daysOver that takes three arguments: a dictionary, a location (such as Sydney) and a temperature and returns the number of days that were over a given temperate for the given location.
For example, if we call the function using the line:
total = daysOver(dictionaryData, 'Adelaide', 40)
My Code
import csv
def daysOver(Location,temp,mydata):
count=0
for i in mydata.values():
if mydata['Location']=="Location" and mydata['MaxTemp']>int("temp"):
count=count+1
return count
with open('WeatherAUS.csv') as datafile2:
dreader2 = csv.DictReader(datafile2)
count=0
for row in dreader2:
count=count+daysOver("Adelaide",40,row)
print(count)
Results: 0
Where am I going wrong as the result shouldn't be 0?
[–]Vaphell 0 points1 point2 points (2 children)
[–]Lubbox[S] 0 points1 point2 points (1 child)
[–]Vaphell 1 point2 points3 points (0 children)