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 trialKai Huang
9,369 PointsMy answer is wrong but I think it is correct
Is there anything wrong with my code?
Kai Huang
9,369 PointsOh sorry, Didn't notice I didn't add the code in. Do let me know why this answer isn't working. Thanks!
def mod(a, b)
return "The remainder of #{a} divided by #{b} is #{a%b}"
end
Jordan Gauthier
5,552 PointsI haven't learned ruby yet, but could it be that you are attempting to get the remainder of a / c rather than a / b?
Instead of #{a%c}, should it instead be #{a%b}?
2 Answers
Kai Huang
9,369 PointsAh I have found out the mistake, apparently I need to set
c = a % b
first before inserting #{c} into the puts statement
Jason Anello
Courses Plus Student 94,610 PointsMy answer came in a little late here but you don't need to create a c
variable. What you had posted above was fine with the exception of the missing period.
Jason Anello
Courses Plus Student 94,610 PointsHi Kai,
The only issues is that you're missing a period to end the sentence. The challenge is looking for an exact match on the string and the example in the instructions has a period at the end.
Sometimes the challenges are a little lenient and will accept answers without things like periods but the best thing to do is always try to match the output exactly.
Justin Horner
Treehouse Guest TeacherJustin Horner
Treehouse Guest TeacherHello Kai,
Please post your code so we can check it out.