title: Jinja2 list is undefined
body: <p>In Jinja2 I want to print the length of the 'first' value in a dictionary. In Python this would be done with the command <code>len(list(my_dict.values())[0])</code>.</p>
  
  <p>When I try this in Jinja2 I get the error <code>jinja2.exceptions.UndefinedError: 'list' is undefined</code>.</p>
  
  <p>Minimum working example:</p>
  
  <pre><code>from jinja2 import Template, DebugUndefined
  from shutil import copyfile
  
  
  def main(file_name_template, file_name_log):
  
      # Copy template file 'file_name_template' to 'file_name_log' so that logging can start.
      copyfile(file_name_template, file_name_log)
      template = Template(open(file_name_log).read(), undefined=DebugUndefined)
  
      # Define test variable 'my_dict'.
      my_dict = {'key_0': 4641896,
                 'key_1': 189478415,
                 'key_2': 841653}
  
      # Start logging.
      template_render_dict = {'my_dict': my_dict}
  
      # Save log to external file and possibly open upon completion of the 'main' program.
      template_rendered = template.render(template_render_dict)  # Render the template to the filled in log report.
  
  
  if __name__ == "__main__":
      main("template.html", "template_rendered.html")
  </code></pre>
  
  <p>with in <code>template.html</code> the code</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
      &lt;body&gt;
          {{my_dict}}&lt;br/&gt;
          {{my_dict.keys()}}&lt;br/&gt;
          {{my_dict.values()}}&lt;br/&gt;
          {{len(list(my_dict.values())[0])}}&lt;br/&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>How do I solve this?</p>