title: How to access a class object inside a list when a value for one of the class attributes is given in Python?
body: <p>I have a list of class objects and I want to know how can I print a particular class object inside the list given a value for one of its attributes.</p>
  <p>Here is my code:</p>
  <pre><code>class Person:
    def __init__(self, name, age):
      self.name = name
      self.age = age
  
  lst = [Person(&quot;A&quot;,1), Person(&quot;B&quot;,2), Person(&quot;C&quot;, 3)]
  
  inputAge = int(input(&quot;Age: &quot;))
  
  if inputAge == 2:
    print() #this should print the class object with age 2 from the list 
  </code></pre>
  <p>I don't know what should I put inside the <code>print()</code> code.</p>