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 trial

Python Customizing Django Templates Building Custom Filters Pluralize

Cao Shuyang
Cao Shuyang
17,959 Points

Challenge Task 4 of 4 Add a conditional that prints, "Wow, that's a lot of elves!" if there are more than 5 elves.

I don't see what is wrong with my code, please help!

code_challenges/templates/code_challenges/list.html
{% if num_elf <= 5 %}
   {{ num_elf }} el{{ num_elf|pluralize:"f,ves" }}
{% else %}
    "Wow, that's a lot of elves!"
{% endif %}

4 Answers

Hey Cao, It only says you should add this not include first task into (if)

{{ num_elf }} el{{ num_elf|pluralize:"f,ves" }} {% if num_elf > 5 %} "Wow, that's a lot of elves!" {% endif %}

This worked for me.

V K
V K
5,237 Points
{{ num_elf }} el{{ num_elf|pluralize:"f,ves" }}
{% if num_elf > 5 %}"Wow, that's a lot of elves!"{% endif %}
Bogdan Lalu
Bogdan Lalu
6,419 Points

There does seem to be an issue with the 4th step in this challenge. I've had an issue as well and I've used the exact code that Cubes School posted here to figure it out. My conclusion is that you need to make sure you put spaces between all elements in this expression {% if num_elf > 5 %} For some reason it does not accept the solution it if there is no space between the 'greater than' sign and 5.

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,858 Points

Hey Cao,

It's been a while since I've done this course, and I don't code in Python, but it looks like the challenge is asking for the conditional to check if there are more than 5 elves, but it doesn't say anything about an if/else clause.

So, I would try just using if

eg.

if num_elves > 5
print "Wow, that's a lot of elves!"

Also, it says "Greater than 5" so you cannot have >= just the > symbol.

See if that works out. :) :dizzy:

Cao Shuyang
Cao Shuyang
17,959 Points

Thanks Jason, but I don't think it's the case. I still appreciate your reply!