[Need Help]Build Python Web Apps with Flask: If Statements Exercise - 5

Hello fellow learners and cohorts. I hope you all are having a blessed day.
I am currently on if statements section of Jinja 2 Templates section of Web Apps with Flask skill path. I am currently stuck at instruction 4 which is as follows:

In the Ingredients section surround the 3rd ingredient <li> line with an if statement. For the condition, test that the length of template_ingredients is equal, == , to 3.

After completing this think about how limiting this task is. What if we have an ingredients list greater than 3? What if there’s only one ingredient? Run the code and move to the next exercise to find the answer

The exercise can be found hereIf Statements

It tried the following solution :point_down::

    <h3>Ingredients - {{ template_ingredients | length}}</h3>
      <li>{{ template_ingredients[0] }}</li>
      <li>{{ template_ingredients[1] }}</li>
      <!-- Insert ingredient if statement -->
      { % if {{template_ingredients | length == 3}} % }
      <li>{{ template_ingredients[2] }}</li>
      { % endif % }
      <!-- Be sure to close with an endif block -->

The above code produces the following output :point_down::
snip 1

I would be extremely grateful if someone could guide me through it.

A word of wisdom to pro coders, kindly type the code instead of vague solutions. I have seen nothing but severely negative remarks from the previous learners in regards to this skill path highlighting the problems where helpers are telling people what to do instead showing how it’s dome or where they are wrong in the code.

Thank you in advance for all the help and support. Have a blessed day/week ahead of you :slightly_smiling_face:

If you’re wondering why many folks keep things vague it’s because learners often get less out of a lesson if they’re just given the solution. What benefit would working code be in a learning environment if you don’t learn why the code works? Debugging and problem-solving are skills in their own right that should be tested and practised, how else would you ever write your own apps? Posts that hint at an answer and encourage a learner to solve their own problem are normally much harder to compose than simply providing an answer. Make the most of them :stuck_out_tongue_closed_eyes:.

Have another look at the examples provided, your code is different to those provided on the left hand side and syntax matters.

1 Like

So basically you are not going to help me. Then why am I here? What is the point of this forum? Let me ask codecademy about this. If this is how this platform is going to treat it’s learners then I am better off of it.

How about I meet you in the middle…

Go back and read the lesson material again. You’ll notice there’s an example of how to implement an if in Jinja, which is almost but not quite the solution for what you’re asked to implement.

Compare your attempt to that example, and you should quickly notice why your code is incorrect.