Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialtoirleachomalley
11,979 PointsProblems with Task 2 in this quiz. It is the only outstanding item I have from finishing the Flask basics.
I've tried several attempts at this but without any debugging or being able to see the relevant objects, I cannot complete this. This means I do not complete the course...mega frustrated and sad face!!
my final attempt. I know it is something simple but I'm just very frustrated at this point. Perhaps being able to do a bit of debugging in more challenging quizzes would be an idea??
<ul class="teachers">
{% for teacher in teachers %}
<li><h2>{{ teacher.get('name') }}</h2>
<ul class="courses">
{% for course in teacher.courses() %}
<li>{{ course }}</li>
{% endfor %}
</ul>
</li>
{% endfor %}
</ul>
from flask import Flask, render_template
from teachers import TEACHERS
app = Flask(__name__)
@app.route('/')
def index():
return render_template("teachers.html", teachers=TEACHERS)
<ul class="teachers">
{% for teacher in teachers %}
<li><h2>{{ teacher.get('name') }}</h2>
<ul class="courses">
{% for course in teacher.courses() %}
<li>{{ course }}</li>
{% endfor %}
</ul>
</li>
{% endfor %}
</ul>
1 Answer
Steven Parker
231,275 PointsYou're really close!
But courses isn't a method in itself. You could access it using the get method like you did with name, or you could just access it directly.
toirleachomalley
11,979 Pointstoirleachomalley
11,979 Pointswow, i thought I had tried that BUT I had a typo in the code when I did. Schoolboy error of having {$ instead of {% in one of jinja endfor tags. This is what I was trying to get at in relation to the debug or even better error messages coming from the quiz environment. It makes it very difficult to track down silly issues like this.
Thanks for the help. It is always good to get a second pair of eyes in the search.