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 trialAkshay Ramdasi
14,065 Pointsproblem solving in this challenge
Use string interpolation to return the remainder inside the sentence “The remainder of a divided by b is c.” where a is your “a” variable, b is your “b” variable, and c is the value of a % b.
def mod(a, b)
#write your code here
c = "The remainder of #{a} divided by #{b} is c: "
return a%b
end
3 Answers
mikes02
Courses Plus Student 16,968 PointsYou're really close, you just have it mixed up a little bit.
def mod(a, b)
#write your code here
c = a % b
return "The remainder of #{a} divided by #{b} is #{c}."
end
We need to get the value of C which is the remainder of A divided by B so we can do that by making a 'c' variable and assigning it the value of that division. Then it is asking to return a complete sentence that uses interpolation to show the actual values, so now that we have the value of 'c' we can use return to format our sentence based on the instructions.
Maximiliane Quel
Courses Plus Student 55,489 PointsSo what the code challenge is asking is to return the remainder inside the sentence. That's what goes after the return statement.
c is the variable that you set to the remainder and then you use sting interpolation to replace the a and b in the sentence with the values that are passed in and c with the value that you calculated with the variable:
def mod(a, b)
#write your code here
c = a%b
return "The remainder of #{a} divided by #{b} is #{c}."
end
does that help?
Maximiliane Quel
Courses Plus Student 55,489 Pointssorry for crossposting
Akshay Ramdasi
14,065 PointsThank you!