title: Access attributes of objects in a list
body: <p>I'm using a book called <em>Python for Absolute Beginners</em> and am doing a challenge in the book's chapter 8 (<em>Software Objects</em>). My  code works but I want to add another capability to the code; What code do I need to add to feed/play/talk with a specific critter?</p>
  
  <p>In choice #7 of my code (<em>7 - Feed a specific critter</em>), I have written some code but it doesn't work. How might I access/change the attributes of a specific object that the user selects?</p>
  
  <p>Also, any feedback to improve/shorten the code?</p>
  
  <pre><code># Critter Caretaker
  # A virtual pet to care for
  class Critter(object):
      import random
      """A virtual pet"""
      def __init__(self, name, hunger = random.randint(0,9), boredom = random.randint(0,11)):
          self.name = name
          self.hunger = hunger
          self.boredom = boredom
  
      def __pass_time(self):
          self.hunger +=1
          self.boredom +=1
  
      def __str__(self):
  
          m = "name is: {}, hunger is: {}, boredom is: {}".format(self.name, self.hunger,self.boredom)
  
  
          return m
  
      @property
      def mood(self):
          unhappiness = self.hunger + self.boredom
          if unhappiness &lt;5:
              m = "happy"
          elif 5 &lt;= unhappiness &lt;=10:
              m = "okay"
          elif 11 &lt;= unhappiness &lt;=15:
              m = "frustrated"
          else:
              m= "mad"
          return m
  
      def talk(self):
          print("I'm", self.name, "and I feel", self.mood, "now.\n")
          self.__pass_time()
  
      def eat(self, food=3):
          print("Yummy! Thank you.")
          self.hunger -=food
          if self.hunger &lt;0:
              self.hunger = 0
          self.__pass_time()
  
      def play(self, fun=4):
  
          print("That was fun! Thanks")
          self.boredom -=fun
          if self.boredom &lt;0:
              self.boredom = 0
          self.__pass_time()
  
  def main():
      noc = []
      noc.append(Critter("Chicken"))
      print("An critter named Chicken has been created")
      choice = None
      while choice != "0":
          print \
          ("""
          Critter Caretaker
  
          0 - Quit
          1 - Listen to all your critters
          2 - Feed all your critters
          3 - Play with all your critters
          4 - Create a new critter
          5 - Show a list of critters
          6 - Delete a critter
          7 - Feed a specific critter
          """)
  
          choice = input("Choice: ")
          print()
  
          # exit
          if choice == "0":
              print("Good-bye.")
  
          # listen to critters
          elif choice == "1":
              if len(noc) != 0:
                  i.talk()
              else:
                  print("No critters exist")
          # feed your critters
          elif choice == "2":
              if len(noc) != 0: 
                  for i in noc:
                      print(i.name, "says:", end = " ")
                      i.eat()
          # play with your critters
          elif choice == "3":
              if len(noc) != 0: 
                  for i in noc:
                      print(i.name, "says:", end = " ")
                      i.play()
              else:
                  print("No critter exists")
          # Create a new critter
          elif choice == "4":
              noc.append(Critter(input("Enter a name for your new critter: ")))
          # Show critters
          elif choice =="5":
              b = 0
              if len(noc) != 0: 
                  for i in noc:
                      b +=1
                      print(b, "." ,i.name)
              else:
                  print("No critter exists")
          # delete a critter
          elif choice == "6":
              a = int(input("Enter the serial number of critter you want to delete: "))
              a = a -1
              del noc[a]
  
          # feed a specific critter
          elif choice == "7":
              sctd = input("Enter name of critter you want to feed: ")
              if sctd in noc:
                  noc.eat()
              else:
                  print("That critter doesn't exists")
  
  
          # print attributes of critters
          elif choice == "919":
              for i in noc:
                  print(i)
          else:
              print("\nSorry, but", choice, "isn't valid.")
  
  main()
  ("\n\nPress the enter key to exit.")
  </code></pre>