old_contents: class Garden(object):
  
      __plant_names = {"C": "Clover", "G": "Grass",
                       "R": "Radishes", "V": "Violets"}
  
      def __init__(self, diagram,
                   students=("Alice Bob Charlie David "
                             "Eve Fred Ginny Harriet "
                             "Ileana Joseph Kincaid Larry").split()):
          self.plant_rows = diagram.split()
          self.students = sorted(students)
  
      def plants(self, student):
          slot_start = self.students.index(student) * 2
          slot = slice(slot_start, slot_start + 2)
          return [self.__plant_names[abbrev]
                  for abbrev in (self.plant_rows[0][slot] +
                                 self.plant_rows[1][slot])]
  
new_contents: class Garden(object):
  
      STUDENTS = [
          "Alice",
          "Bob",
          "Charlie",
          "David",
          "Eve",
          "Fred",
          "Ginny",
          "Harriet",
          "Ileana",
          "Joseph",
          "Kincaid",
          "Larry",
      ]
      PLANTS = {"C": "Clover", "G": "Grass", "R": "Radishes", "V": "Violets"}
  
      def __init__(self, diagram, students=None):
          students = sorted(students or self.STUDENTS)
          front, back = diagram.splitlines()
          self.cups = {}
          for idx, student in enumerate(students[: len(front)]):
              start = idx * 2
              stop = start + 2
              self.cups.setdefault(student, [])
              self.cups[student].extend(
                  self.PLANTS[p] for p in front[start:stop]
              )
              self.cups[student].extend(
                  self.PLANTS[p] for p in back[start:stop]
              )
  
      def plants(self, student):
          return self.cups.get(student, [])
  
subject: improve example.py (#1843)