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

How should my sentence be formated?

I get bummer on my code because it is not formatted correctly. It seems to me that the sentence comes out like it should. What am I doing wrong?

def mod(a, b)
  puts "The remainder of #{a} divded by #{b} is "
  return a % b

puts mod(9, 4)

1 Answer

Stephen Beckstrand
Stephen Beckstrand
11,169 Points

Right now, your code is returning two lines, and not a complete sentence:

The remainder of 9 divded by 4 is

You want to have it all returned as one line as a complete sentence. Do something like this:

def mod(a, b)
  return "The remainder of #{a} divided by #{b} is #{a % b}."


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

Also, It helps to be able to review the existing questions and documentation to answer questions. When going to the discussion page for this challenge, you can see that several others have asked similar questions and received answers:

All discussions:


Few that could have helped you:



Thanks for such clear explanations. This was definitely a duh moment for me. I greatly appreciate the resources as well.