# 17. Loop the loop with loop

#1

I am receiving an error message stating "Oops, try again. It looks like you didn't print the string "Ruby" 30 times". But I can clearly see and count the word ruby 30 times in the results box. What is wrong here?

i = 0

loop do
i += 1
print "ruby"
break if i > 30
end

#2

What value will have your `i` variable when the break condition will be fulfilled?

#3

EDIT: I changed the > to == and it worked. Thank you.

I'm sorry. I don't understand the question. I caved and looked at the hint they provided. With exception to their using counter as the variable name, I don't know what is different.

counter = 0
loop do
counter += 1
print "Ruby"
break if counter > # The value to stop at
end

#4

The goal of your loop is to priint something 30 times.

To do that you're using a variable called `i`, which starts at 0.

Then in your loop you have a condition which, if true, will break the loop.

Before your change, this condition was `if i > 30`, but since you increment `i` before this condition is evaluated, your `i` will pass on 31 BEFORE the break occurs. That's why you were printing 31 times "Ruby!" and not 30.

#5

assign i to 1, then it will print 30 time.

#6

i am having the same problem counter = 1
loop do
counter += 1
print "Ruby "
break if counter >30
end
*Oops, try again. It looks like you didn't print out the string 'Ruby!' 30 times.
But it print in screan 30 times wats wrong . Thnks

#7

If I remember the exercise you're supposed to print exactly "Ruby!", not "Ruby ".

#8

Here , try this
counter = 0
loop do
counter += 1
print "Ruby!"
break if counter >= 30
end
adding only > will make ruby think it could stop at 31,32, 33 e.t.c. and that is not specific enough and would be confusing, but adding = makes the code more specific by telling ruby to break once its 30 exactly

#9

No, I think it's this:
counter = 0
loop do
counter += 1
print "Ruby!"
break if counter == 30
end

Does it work?

#10

why wont this work
oop do
i += 1
30.times {print "'Ruby!'"}
break if i == 10
end

#11

i= 0
loop do
i += 1
30.times {print "'Ruby!'"}
break if i == 30
end

why wont this work

Ruby 17/19
#12

counter = 0
loop do
counter += 1
30.times {print "Ruby!"}
break if counter <= 30
end

#13

No must be > 29 to work

#14