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 trialCao Shuyang
17,959 PointsChallenge 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!
{% if num_elf <= 5 %}
{{ num_elf }} el{{ num_elf|pluralize:"f,ves" }}
{% else %}
"Wow, that's a lot of elves!"
{% endif %}
4 Answers
Cubes School
Courses Plus Student 17,884 PointsHey 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
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
6,419 PointsThere 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
Treehouse Moderator 145,860 PointsHey 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. :)
Cao Shuyang
17,959 PointsThanks Jason, but I don't think it's the case. I still appreciate your reply!
Cao Shuyang
17,959 PointsCao Shuyang
17,959 PointsThanks a lot!