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 trialCarmine Lentini
4,449 PointsReturn in a string
I tried in a lot of ways, but i can't find the rigth way to resolve it, where im wronging?
6 Answers
Noryhng Lazo
16,879 PointsRemainder is misspelled.
Noryhng Lazo
16,879 PointsYou need to first assign the solution of the modulus operator to the variable "c". Then return the string with "a", "b" and "c" interpolated.
Here is what I would do:
def mod(a, b)
c = a % b
return "The remainder of #{a} divided by #{b} is #{c}."
end
Fill in the string with the correct interpolation and you should be fine. I didn't want to give away the complete answer.
Carmine Lentini
4,449 PointsHello, thank you for the answer, i did try to write this code several times, but the site give to me the following answer: Something doesn't look quite right. Double check your spelling and punctuation.
def mod(a, b) #write your code here c = a % b return "The reminder of #{a} divided by #{b} is #{c}."
end
mod(9,2)
Noryhng Lazo
16,879 PointsTry is without calling the method mod(9,2). That's extra code that you don't need.
Carmine Lentini
4,449 PointsI don't know where i'm wrong but i think it is correct!
def mod(a, b)
#write your code here
c = a % b
return "The reminder of #{a} divided by #{b} is #{c}."
end
Carmine Lentini
4,449 PointsI can't believe that i wrote Remainder in a wrong way and i didn't pay attention to it. now it's work, thank you so much for the help, and shame of me ahah .
Carmine Lentini
4,449 PointsCarmine Lentini
4,449 Pointsdef mod(a, b) #write your code here
puts "The reminder of #{a} divided by #{b} is #{c}" return a % b end
puts mod(9, 2)