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 trialBrian Patterson
19,588 PointsNot sure why I am getting a syntax error.
def mod(a, b)
#write your code here
puts βThe remainder of #{a} divided by #{b} is c.β
return a % b
end
Not sure why I am getting a syntax error?
2 Answers
Steve Hunter
57,712 PointsHi Brian,
It wants you to return
the string, not puts
it. So, you use string interpolation for a
, b
and c
.
Something like:
def mod(a, b)
#write your code here
c = a % b
return "The remainder of #{a} divided by #{b} is #{c}."
end
I hope that helps,
Steve.
Ethan Weeks
15,352 PointsYou are very close but the challenge is looking for the string to be returned. First we have to declare c to be the remainder of a modulo b Second we return our string with all the variables inserted.
def mod(a, b)
#write your code here
c = a % b
return "The remainder of #{a} divided by #{b} is #{c}."
end
Brian Patterson
19,588 PointsThanks for your help.
Steve Hunter
57,712 PointsSteve Hunter
57,712 PointsIndeed, you don't need to use
c
at all, you can interpolate the result of the mod operator:return "The remainder of #{a} divided by #{b} is #{a % b}."
Brian Patterson
19,588 PointsBrian Patterson
19,588 PointsThank you for your reply.
Steve Hunter
57,712 PointsSteve Hunter
57,712 PointsNo problem, Brian. Glad you got it fixed. :-)
Steve.