# 15. Looping with 'Until' error

i = 1
while i <= 50 do
print i
i += 1
end

j = 1
until j == 51 do
print j
j += 1
end

this code is creating the desired output but its still saying u didn’t print 1 through 50, inclusive. Help me out folks.

Do you have both of these loops in your code? Because I think they’re only asking for one right?

So wait, all I gotta do is put 51? How does that make sense? I had that originally but why would you have ("==" equal to) 51? I feel like it’s technically saying is equal to 51. I don’t know. I can’t wrap my brain around this.

1 Like

51 or 50 can work just as well, it all depends on the type of loop you use and the condition you use with them.

try this

i = 1
while i <= 50 do
print i
i += 1
end

i = 1
until i <= 50 do
print i
i += 1
end

Try this code. This one worked for me.

i = 1
until i == 51 do
print i
i += 1
end

I have the same question opdlnando. Bump.
Why does this code only go to 49?

``````i = 1
until i == 50 do
print i
i += 1
end
``````

I believe it is due to the fact that the until loop will execute that line of code “until” that condition is true. So, if i = 50, that means the condition is now true therefore it would not run that loop. Hope that helps! v

this will work

i = 1
until i > 50 do #it should be greater not equal or less than 50
print i
i += 1

end

Thank you. It works.