FAQ: Loops & Iterators - Looping with 'Until'

Hi Midlidner,

I have a question for you but I incorrectly only sent it to bit4005433864. I would appreciate if you could please take a look at it as well.

Here it is:

Version:1.0 StartHTML:000000243 EndHTML:000040024 StartFragment:000009080 EndFragment:000039976 StartSelection:000009660 EndSelection:000039929 SourceURL:FAQ: Loops & Iterators - Looping with 'Until' - #5 by core2682479141 FAQ: Loops & Iterators - Looping with ‘Until’ - Guide / Ruby FAQ - Codecademy Forums {"@context":“http://schema.org","@type”:“WebSite”,“url”:“https://discuss.codecademy.com",“potentialAction”:{"@type”:“SearchAction”,“target”:“Search results for '{search_term_string}","query-input":"required' - Codecademy Forums name=search_term_string”}} {"@context":“http://schema.org","@type”:“QAPage”,“name”:“FAQ: Loops & Iterators - Looping with ‘Until’”,“mainEntity”:{"@type":“Question”,“name”:“FAQ: Loops & Iterators - Looping with ‘Until’”,“text”:"<a class=“lightbox” href="//codecademy-discourse.s3.dualstack.us-east-1.amazonaws.com/original/5X/d/8/8/1/d88176b1e3cf3b7c8c9b1ac4a094dd5d21447876.jpeg" title=“Community FAQs on Codecademy Exercises.jpeg” rel=“nofollow noopener”>[Community%20FAQs%20on%20Codecademy%20Exercises]</a>\nThis community-built FAQ covers the “Looping with ‘Until’” exercise from the lesson “Loops & Iterators”. \nPaths and Courses \nThis exercise can be found in the following Codecademy content: \n<a href=“http://codecademy.com/courses/learn-ruby/lessons/loops-iterators/exercises/looping-with-until” rel=“nofollow noopener”>Learn Ruby</a> \nFAQs on the exercise Looping with ‘Until’\n\n\nThe…",“upvoteCount”:0,“answerCount”:0,“dateCreated”:“2018-10-26T00:04:49.923Z”,“author”:{"@type":“Person”,“name”:“Wiki Bot”}}} #reply-control .d-editor-preview img:not(.thumbnail), .cooked img:not(.thumbnail) {max-width:690px;max-height:500px;} /* Copyright 2014 Evernote Corporation. All rights reserved. */ .en-markup-crop-options { top: 18px !important; left: 50% !important; margin-left: -100px !important; width: 200px !important; border: 2px rgba(255,255,255,.38) solid !important; border-radius: 4px !important; } .en-markup-crop-options div div:first-of-type { margin-left: 0px !important; }

Hi.

I have been trying to use this solution you gave as a model for the solution to the Instructions for Lesson 5 Section 15 but I just can’t seem to figure it out. I think I’m confused about the range from 0-50 for the j = 3 section . Every time I try a new code using < 50 or 1…50 I end up in an endless loop.

i = 3
while i > 0 do
print i
i -= 1
end

j = 3
until j == 0 do
print j
j -= 1
end

Now rewrite your while loop using until . You still want to print out the numbers 1 through 50, inclusive.

This is one of my many attempts which is wrong:

j = 3
until j ==0 < 50 do
print j
j -= 1
end

Thanks for any explanation you can give me.

Reply

Bookmark Share Flag Reply

Unpinned

This topic is unpinned for you; it will display in regular order

Tracking

You will see a count of new replies because you posted a reply to this topic.

Suggested Topics

Topic Replies Views Activity
FAQ: Getting Started - Generalizations

Ruby FAQ|1|163|Feb 2|
|FAQ: Introduction to Ruby - Multi-Line Comments

Ruby FAQ|2|201|Nov '18|
|FAQ: The Zen of Ruby - Conditional Assignment

Ruby FAQ|0|135|Nov '18|
|FAQ: Data Structures - Iterating Over Arrays

Ruby FAQ|0|133|Nov '18|
|FAQ: Data Structures - Creating Arrays

Ruby FAQ|0|155|Nov '18|

There are 31 new topics remaining, or browse other topics in Ruby FAQ

[en_US.share.topic]

New Topic

Quote

Invalid dateInvalid date

midlindner

Hi Midlidner,

I have a question for you but I incorrectly only sent it to bit4005433864. I would appreciate if you could please take a look at it.

Hi.

I have been trying to use this solution you gave as a model for the solution to the Instructions for Lesson 5 Section 15 but I just can’t seem to figure it out. I think I’m confused about the range from 0-50 for the j = 3 section . Every time I try a new code using < 50 or 1…50 I end up in an endless loop.

i = 3
while i > 0 do
print i
i -= 1
end

j = 3
until j == 0 do
print j
j -= 1
end

Now rewrite your while loop using until. You still want to print out the numbers 1 through 50, inclusive.

This is one of my many attempts which is wrong:

j = 3
until j ==0 < 50 do
print j
j -= 1
end

Thanks for any explanation you can give me.