Advertisement
Guest User

Untitled

a guest
Apr 26th, 2015
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. Month, Jan, Feb, March....etc.
  2.  
  3. def hottest_city(csv_filename):
  4. import csv
  5. file = open(csv_filename)
  6. header = next(file)
  7. data = csv.reader(file)
  8. city_maxlist = []
  9. for line in data:
  10. maxtemp = 0.0
  11. for temp in line[1:]:
  12. if float(temp >= maxtemp:
  13. maxtemp = float(temp)
  14. city_maxlist.append([maxtemp, line[0])
  15. maxtempcity = 0.0
  16. for city in city_maxlist:
  17. if city[0] >= maxtempcity:
  18. maxtempcity = city[0]
  19. citylist = []
  20. for line in data:
  21. for temp in line:
  22. if temp == maxtempcity:
  23. citylist.append(line[0])
  24. return (maxtempcity, citylist)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement