What is wrong with this?

i = 1

while i < 51

print i

i += 1

end

j=50

until j==50 do

print j

j-=50

end

for k in 1…50

print k

end

What is wrong with this?

i = 1

while i < 51

print i

i += 1

end

j=50

until j==50 do

print j

j-=50

end

for k in 1…50

print k

end

No idea. I have the same problem though.

1 Like

I googled it. Delete your first 2 loops leaving the last one you’ve written and it should work.

3 Likes

I had to do the same thing. I kept getting an error with the right code but It finally worked once I deleted the former lines of code.

2 Likes

i = 1

while i < 51

print i

i += 1

end

j=50

until j==50 do

print j

j-=50

end

k=50

for k in 1…50

print

end

How do I get my loop to stop

counter = 10

until counter>10

puts counter<10

end

If you want you can use my, because i don’t know how to help you.

Thanks, you advice worked like a charm

Loop the Loop with Loop:

counter = 0

loop do

counter += 1

print “Ruby!”

break if counter == 30

end

There are two ways to count number with “until” from 0 to 10.

counter = 0

until counter > 10

puts counter

counter += 1

end

counter = 10

until counter < 0

puts counter

counter -= 1

end