title: How to change a random turtle's color?
body: <p>I need to choose a person randomly from a list then infect them with the virus (changing their turtle color to red) when I press 'x'.  Then I have to count how many people are infected.</p>
  
  <p>Currently, my code does not change any turtle's color and I also don't know how to count how many red turtle are there.</p>
  
  <pre><code>#used to infect 
  class Virus:
      def __init__(self, colour, duration):
          self.colour = colour
          self.duration = duration
  class Person:
      def __init__(self, world_size):
          self.world_size = world_size
          self.radius = 7
          self.location = turtle.position()
          self.destination = self._get_random_location()
          turtle.penup()
          turtle.setposition(self.location)
          turtle.setheading(turtle.towards(self.destination))
          self.heading = turtle.heading()
  
      #random locations are used to assign a destination for the person
      #the possible locations should not be closer than 1 radius to the edge of the world 
      def _get_random_location(self):
          x = random.randint( - 349, 349 )
          y = random.randint( - 249, 249 )
          return (x, y)
  
  
      #draw a person using a dot.  Use colour if implementing Viruses 
      def draw(self):
          x, y = self.location
          turtle.penup()
          turtle.setposition(x, y - self.radius)
          turtle.pendown()
          turtle.begin_fill()
          self.x = turtle.circle(self.radius)
          turtle.end_fill()
  
  #infect a person with the given virus
      def infect(self, virus):
          v_colour = virus.colour
          turtle.colormode("v_colour")
  class World:
      def __init__(self, width, height, n):
          self.size = (width, height)
          self.hours = 0
          self.people = []
          self.infected = 0
          for i in range(n):
              self.add_person()
  
  
      #add a person to the list
      def add_person(self):
          person = Person(1)
          self.people.append(person)
  
  
      #choose a random person to infect and infect with a Virus when press 'x'
      def infect_person(self):
          random_ppl = random.choice(self.people)
          v = Virus("red", 100)
          random_ppl.infect(v)
  
      #remove all infections from all people when press'c'
      def cure_all(self):
          turtle.colormode('black')
          self.infected = 0
  
  def draw(self):
          turtle.clear()
          turtle.hideturtle()
          turtle.setheading(0)
          turtle.penup()
          turtle.setposition(-350, -250)
          turtle.pendown()
  
          for i in range(2):
              turtle.forward(500)
              turtle.right(90)
              turtle.forward(700)
              turtle.right(90)
  
          for item in self.people:
              item.draw()
  
          turtle.penup()
          turtle.setposition(-350, 250)
          turtle.write(f'Hours: {self.hours}', move=False, align='left')
          self.count_infected()
          turtle.setposition(0, 250)
          turtle.write(f'Infected: {self.infected}', move=False, align='left')
          turtle.update()
  
  
  
      #Count the number of infected people
      def count_infected(self):
          p = Person(1)
          p.draw()
          dot = p.x
          color = dot.color()
          Color = color[0]
          if Color is 'red':
              self.infected += 1
  
  #code for the keys
  class GraphicalWorld:
      """ Handles the user interface for the simulation
  
      space - starts and stops the simulation
      'z' - resets the application to the initial state
      'x' - infects a random person
      'c' - cures all the people
      """
      def __init__(self):
          self.WIDTH = 800
          self.HEIGHT = 600
          self.TITLE = 'COMPSCI 130 Project One'
          self.MARGIN = 50 #gap around each side
          self.PEOPLE = 200 #number of people in the simulation
          self.framework = AnimationFramework(self.WIDTH, self.HEIGHT, self.TITLE)
  
          self.framework.add_key_action(self.setup, 'z') 
          self.framework.add_key_action(self.infect, 'x')
          self.framework.add_key_action(self.cure, 'c')
          self.framework.add_key_action(self.toggle_simulation, ' ') 
          self.framework.add_tick_action(self.next_turn)
  
          self.world = None
  
      def setup(self):
          """ Reset the simulation to the initial state """
          print('resetting the world')        
          self.framework.stop_simulation()
          self.world = World(self.WIDTH - self.MARGIN * 2, self.HEIGHT - self.MARGIN * 2, self.PEOPLE)
          self.world.draw()
  
      def infect(self):
          """ Infect a person, and update the drawing """
          print('infecting a person')
          self.world.infect_person()
          self.world.draw()
  
      def cure(self):
          """ Remove infections from all the people """
          print('cured all people')
          self.world.cure_all()
          self.world.draw()
  </code></pre>
  
  <p>The homework calls <code>World.infected_people()</code> first so I don't know how to pass the random people to <code>Person.infect()</code> then change the color.</p>