Possible Glitch on Looping With While?


#1



Seems I'm having a problem with:

14. Looping With While


The console prints out 1 to 50, but then I get this error:

Oops, try again. It looks like you didn't print out the numbers 1 to 50, inclusive.

The error shouldn't be there at all, I even printed the "1" so that gets rid of the "inclusive" part.


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


#2

What about 50


#3

In case anyone is looking for help resolving this the number has to be 51 to print to 50.

while i < 51 do


#4

Hi
say
i = 1
while i < 51 do
print i
i +=1
end # :slight_smile:


#5

Its almost right, your telling 'i' to print everything less than 50
thats why 1-49 only prints with;
while i < 50

use instead; while i <= 50

and it'll print 1-50 since its less than and equal to 50


#6

i = 0

while i < 50 do
i += 1
print "#{i}"
end


#7

Thanks finaly it worked :slight_smile:


#8

I've done this in different way, but also with <=

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