title: Creating Object With A For Loop
body: <p>Firstly, I do apologise as I'm not quite sure how to word this query within the Python syntax. I've just started learning it today having come from a predominantly PowerShell-based background.</p>
  
  <p>I'm presently trying to obtain a list of projects within our organisation within Google Cloud. I want to display this information in two columns: project name and project number - essentially an object. I then want to be able to query the object to say: where project name is "X", give me the project number.</p>
  
  <p>However, I'm rather having difficulty in creating said object. My code is as follows:</p>
  
  <pre><code>import os
  from pprint import pprint
  from googleapiclient import discovery
  from oauth2client.client import GoogleCredentials
  
  credentials = GoogleCredentials.get_application_default()
  service = discovery.build('cloudresourcemanager', 'v1', credentials=credentials)
  
  request = service.projects().list()
  response = request.execute()
  projects = response.get('projects')
  </code></pre>
  
  <p>The 'projects' variable then seems to be a list, rather than an object I can explore and run queries against. I've tried running things like:</p>
  
  <pre><code>pprint(projects.name)
  projects.get('name')
  </code></pre>
  
  <p>Both of which return the error:
  "AttributeError: 'list' object has no attribute 'name'"</p>
  
  <p>I looked into creating a Class within a For loop as well, which nearly gave me what I wanted, but only displayed one project name and project number at a time, rather than the entire collection I can query against:</p>
  
  <pre><code>projects=[]
  for project in response.get('projects', []):
      class ProjectClass:
          name = project['name']
          projectNumber = project['projectNumber']
      projects.append(ProjectClass.name)
      projects.append(ProjectClass.projectNumber)
  </code></pre>
  
  <p>I thought if I stored each class in a list it might work, but alas, no such joy! Perhaps I need to have the For loop within the class variables?</p>
  
  <p>Any help with this would be greatly appreciated!</p>