title: Python Assignment problem about voter turnout: class and object and function
body: <pre><code># implement County class here
  class County:
    def __init__(self, name,population,voters):
      self.name=name
      self.population=population
      self.voters=voters
  
    # implement the function here
  
  def highest_turnout(data):
  
  highest_turnout = (data[0].voters)/(data[0].population)
  for county in data:
      if (county.voters/county.population) &gt; highest_turnout:
          highest_turnout= county
  return highest_turnout
  
  allegheny = County("allegheny", 1000490, 645469)
  philadelphia = County("philadelphia", 1134081, 539069)
  montgomery = County("montgomery", 568952, 399591)
  lancaster = County("lancaster", 345367, 230278)
  delaware = County("delaware", 414031, 284538)
  chester = County("chester", 319919, 230823)
  bucks = County("bucks", 444149, 319816)
  data = [allegheny, philadelphia, montgomery, lancaster, delaware, chester, bucks]  
  
  result = highest_turnout(data) # do not change this line!
  print(result) # prints the output of the function
  # do not remove this line!
  </code></pre>
  
  <p>I have to make a python function  in which returns the highest voter turnout  I am only a beginner to programming and the class resources are not really helping. Any help will be very much appreciated. Thanks.</p>
  
  <p>Directions:<br>
  ● First, find the County that has the highest turnout, i.e. the highest percentage of the population who voted, using the objects’ population and voters attributes<br>
  ● Then, return a tuple containing the name of the County with the highest turnout and the
  percentage of the population who voted, in that order; the percentage should be
  represented as a number between 0 and 1</p>
  
  <p>I have already written the class. </p>
  
  <blockquote>
    <p>TypeError: '>' not supported between instances of 'float' and 'County'</p>
  </blockquote>
  
  <p>I have gotten this error. I think my class is right but I am not so sure what to do with this function. The instruction also says to return the county's name and highest voter turnout in a tuple, but I am not so sure how. Please help. Thank you.</p>