# Loop the loop with loop

Continuing the discussion from Loop the loop with loop "break if 30":

I’ve tried all the things that everyone is putting up here… I’ve cut and pasted all the different suggestions and to no avail. I still get “Oops, try again. It looks like you didn’t print out the string ‘Ruby!’ 30 times.”
Just like the last guy it still produces the same result…
Does anybody know why??

This will work, provided `m` is defined

``````m = "Ruby!"
30.times { print "#{m}"}
``````
1 Like

Alright, let’s take a few steps to see if we can find what went wrong.

1. Post the code you used using back-tick notation (underneath the tilde " ~ "):

``````30.times{ print "Ruby!" } #your code here!
``````

It’ll look like this

``````30.times{ print "Ruby!" } #your code here!
``````

1. Post the error, and Instructions for the forum. This pops up when you hit “Save & Submit Code”

m = 1
loop do
m += 1
print "Ruby! "
break if m == 30
end

Oops, try again. It looks like you didn’t print out the string ‘Ruby!’ 30 times.

Try starting with `m = 0`.

1 Like

m = "Ruby! "
loop do
30.times{ print “#{m}”}
break if m > 30
end
every one of these work in the display window… but I still get the “Oops, try again. It looks like you didn’t print out the string ‘Ruby!’ 30 times.”

That’s because you are printing the string, `'Ruby! '` with a trailing space. Take out the space.

There is a big issue here with putting a loop in a loop like that. All that is needed is either one loop or the other.

``````m = 'Ruby!'
30.times {print "#{m}"}
``````

which is a refactoring of,

``````m = "Ruby!"
i = 1
loop do
print "#{m}"
i += 1
break if i > 30
end
``````