title: Update value of object in list
body: <p>I have several lists that each contain objects.  All objects have the values "name" and "amount".  What I want to do is create a method to update "amount" by first finding the item in the list by user input (enter name to find name) then adding or subtracting a user input value (enter value to add/enter value to subtract).</p>
  
  <p>How would I go about doing this?</p>
  
  <p>This is what I have so far (It's incomplete but it's all I could get done):</p>
  
  <pre><code>Containers = []
  Lids = []
  Wicks = []
  Labels = []
  Misc = []
  
      class item(object):
  
          #Constructor
          def __init__(self, name, amount):
              self.name = name
              self.amount = amount
  
          #Accessors
          def getName(self):
              return self.name
  
          def getAmount(self):
              return self.amount
  
  
          #Mutators
          def __str__(self):
              return "[Name: " + self.name + \
                      ", Amount: " + self.amount + \
                      "]"
  
          def addAmount():
              found = False
              name = input("Enter the name of a container you wish to change: ")
              addNewAmount = input("Enter the amount you wish to add: ")
              for item in Containers:
                  if name in item.getName():
                      found = True
                      position = Containers.index(name)
                      print(Containers[position])
              if not found:
                  print("No names match that input.")
  
          def subtractAmount():
              update = input("Enter a new amount to subtract: ")
              self.amount = amount - update
  
          def addContainer():
              name = input("Enter a name for the new container: ")
              amount = input("Enter an amount for the new container: ")
              return item(name, amount)
  
          def addLid():
              name = input("Enter a name for the new lid: ")
              amount = input("Enter an amount for the new lid: ")
              return item(name, amount)
  
          def addWick():
              name = input("Enter a name for the new wick: ")
              amount = input("Enter an amount for the new wick: ")
              return item(name, amount)
  
          def addLabel():
              name = input("Enter a name for the new label: ")
              amount = input("Enter an amount for the new label: ")
              return item(name, amount)
  
          def addMisc():
              name = input("Enter a name for the new misc item: ")
              amount = input("Enter an amount for the new misc item: ")
              return item(name, amount)
  
          def main():
              running = True
              while running:
                  print("Enter a number to start.")
                  print("1) Add new container         2) Add new lid")
                  print("3) Add new wick              4) Add new label")
                  print("5) Add new misc Item         6) Print Inventory")
                  print("7) Add Amount from item      8) Subtract Amount from item")
                  print("10) quit")
                  print("11) print list")
                  choice = input("&gt; ")
                  if choice == "1":
                      Containers.append(addContainer())
                  elif choice == "2":
                      Lids.append(addLid())
                  elif choice == "3":
                      Wicks.append(addWick())
                  elif choice == "4":
                      Labels.append(addLabel())
                  elif choice == "5":
                      Misc.append(addMisc())
                  elif choice == "6":
                      print("&lt;==========Containers==========&gt;")
                      for i in Containers:
                          print(i)
                      print("&lt;=============Lids=============&gt;")
                      for i in Lids:
                          print(i)
                      print("&lt;=============Wicks============&gt;")
                      for i in Wicks:
                          print(i)
                      print("&lt;============Labels============&gt;")
                      for i in Labels:
                          print(i)
                      print("&lt;==========Misc Items==========&gt;")
                      for i in Misc:
                          print(i)
                  elif choice == "7":
                      return addAmount()
                  elif choice == "8":
                      return subtractAmount()
                  elif choice == "10":
                      quit()
                  elif choice == "11":
                      print('[%s]' % ', '.join(map(str, Containers)))
                  else:
                      print("Invalid entry, please try again.")
  
          if __name__ == "__main__":
              main()
  </code></pre>