16. Looping with 'For'


#1

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


#2

No idea. I have the same problem though.


#3

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


#4

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.


#5

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


#6

How do I get my loop to stop
counter = 10
until counter>10
puts counter<10
# Add code to update 'counter' here!

end


#7

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


#8

Thanks, you advice worked like a charm


#9

Loop the Loop with Loop:

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


#10

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