Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Month, Jan, Feb, March....etc.
- def hottest_city(csv_filename):
- import csv
- file = open(csv_filename)
- header = next(file)
- data = csv.reader(file)
- city_maxlist = []
- for line in data:
- maxtemp = 0.0
- for temp in line[1:]:
- if float(temp >= maxtemp:
- maxtemp = float(temp)
- city_maxlist.append([maxtemp, line[0])
- maxtempcity = 0.0
- for city in city_maxlist:
- if city[0] >= maxtempcity:
- maxtempcity = city[0]
- citylist = []
- for line in data:
- for temp in line:
- if temp == maxtempcity:
- citylist.append(line[0])
- return (maxtempcity, citylist)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement