title: How do I return a list as a variable in Python and use in Jinja2?
body: <p>I am a very young programmer and I am trying to do something in Python but I'm stuck. I have a list of users in Couchdb (using python couchdb library &amp; Flask framework) who have a username (which is the _id) and email. I want to use the list of email addresses in a select box in a jinja2 template.</p>
  
  <p>My first problem is how to access the email addresses. If I do:</p>
  
  <pre><code>for user in db:
      doc = db[user]
      emails = doc['email']
      print options
  </code></pre>
  
  <p>I get:</p>
  
  <pre><code>email@domain.com
  otheremail@otherdomain.com
  yetanotheremail@yetanotherdomain.com
  </code></pre>
  
  <p>So I can get my list of emails. But where my brutal inexperience is showing up is that I don't know how to then use them. The list only exists in the for loop. How do I return that list as a useable list of variables? And how do I then make that list appear in my jinja2 template in an option dropdown. I guess I need a function but I am a green programmer.</p>
  
  <p>Would so appreciate help.</p>