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 trial

Ruby Ruby Basics (Retired) Ruby Methods Method Returns: Part 2

Struggling with Ruby question about returning a sentence with string interpolation for remainder of divided numbers

The question that asks about returning the remainder of two numbers in sentence keeps failing even though I am very certain I am doing things right (see my attached code). What do I do?

def mod(a, b)
  #write your code here
  c = a % b
  return "The remainder of #{a} divided by #{b} is #{c}"

1 Answer

28,558 Points

Your code is indeed completely fine. The issue is that these challenges tend to be very picky about strings, they often have to match the example text provided to the letter. The "problem" with your code is that you are missing a period at the end of your string. If you add it then you will be able to pass the challenge.

OH THANK YOU! I was trying to understand what I was doing wrong for so long! Thanks so much!