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 trialmarcolamoon
16,915 Pointsnot understanding
In this final code challenge, you'll create a tag that will return the proper conjugation of the verb "to be" depending on whether the subject is plural or singular. Example: "There is 1 elf" versus "There are 5 elves".
Start by creating a conjugate_is function for your template tag. It should take a number as an argument. If (and only if) that number equals 1, the function should return the string 'is'.
from django import template
register = template.Library()
def conjugate_is(1):
return template(is)
{% load fairy_extras %}
There is {{ num_elf }} el{{ num_elf|pluralize:"f,ves" }}.
3 Answers
Todd Anderson
4,260 PointsYou don't want to pass in the number 1 to your parameter. Pass in a parameter like int, then if the int = 1 return 'is'.
def conjugate_is(int): if int == 1: return 'is'
Christopher Gomez
Courses Plus Student 13,800 Points@marcolamoon have you tired double == like what Todd Anderson did cause it worked for me and don't forget to hit enter before if and return o yea no () on is it's just 'is'
Carson Alexander
Python Web Development Techdegree Graduate 12,172 PointsThis is what is needed to pass the challenge:
def conjugate_is(int):
if int == 1:
return 'is'
marcolamoon
16,915 Pointsmarcolamoon
16,915 Pointsi tried the following code and it wasn't working.
from django import template
register = template.Library()
def conjugate_is(int): if int = 1: return ('is')